1 # Copyright
(C
) 1992, 1997 Free Software Foundation
, Inc.
3 # This
program is free software
; you can redistribute it and
/or modify
4 # it under the terms of the GNU General Public License as published by
5 # the Free Software Foundation
; either version
2 of the License
, or
6 #
(at your option
) any later version.
8 # This
program is distributed in the hope that it will be useful
,
9 # but WITHOUT
ANY WARRANTY
; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the
11 # GNU General Public License
for more details.
13 # You should have received a copy of the GNU General Public License
14 # along with this
program; if not
, write to the Free Software
15 # Foundation
, Inc.
, 59 Temple Place
- Suite
330, Boston
, MA
02111-1307, USA.
17 # Please email
any bugs
, comments
, and
/or additions to this file to
:
18 # bug
-gdb@prep.ai.mit.edu
20 # This file was written by Fred Fish.
(fnf@cygnus.com
)
29 proc test_convenience_variables
{} {
32 gdb_test
"set \$foo = 101" "" \
33 "Set a new convenience variable"
35 gdb_test
"print \$foo" " = 101" \
36 "Print contents of new convenience variable"
38 gdb_test
"set \$foo = 301" "" \
39 "Set convenience variable to a new value"
41 gdb_test
"print \$foo" " = 301" \
42 "Print new contents of convenience variable"
44 gdb_test
"set \$_ = 11" "" \
45 "Set convenience variable \$_"
47 gdb_test
"print \$_" " = 11" \
48 "Print contents of convenience variable \$_"
50 gdb_test
"print \$foo + 10" " = 311" \
51 "Use convenience variable in arithmetic expression"
53 gdb_test
"print (\$foo = 32) + 4" " = 36" \
54 "Use convenience variable assignment in arithmetic expression"
56 gdb_test
"print \$bar" " = void" \
57 "Print contents of uninitialized convenience variable"
60 proc test_value_history
{} {
63 gdb_test
"print 101" "\\\$1 = 101" \
64 "Set value-history\[1\] using \$1"
66 gdb_test
"print 102" "\\\$2 = 102" \
67 "Set value-history\[2\] using \$2"
69 gdb_test
"print 103" "\\\$3 = 103" \
70 "Set value-history\[3\] using \$3"
72 gdb_test
"print \$\$" "\\\$4 = 102" \
73 "Print value-history\[MAX-1\] using inplicit index \$\$"
75 gdb_test
"print \$\$" "\\\$5 = 103" \
76 "Print value-history\[MAX-1\] again using implicit index \$\$"
78 gdb_test
"print \$" "\\\$6 = 103" \
79 "Print value-history\[MAX\] using implicit index \$"
81 gdb_test
"print \$\$2" "\\\$7 = 102" \
82 "Print value-history\[MAX-2\] using explicit index \$\$2"
84 gdb_test
"print \$0" "\\\$8 = 102" \
85 "Print value-history\[MAX\] using explicit index \$0"
87 gdb_test
"print 108" "\\\$9 = 108"
89 gdb_test
"print \$\$0" "\\\$10 = 108" \
90 "Print value-history\[MAX\] using explicit index \$\$0"
92 gdb_test
"print \$1" "\\\$11 = 101" \
93 "Print value-history\[1\] using explicit index \$1"
95 gdb_test
"print \$2" "\\\$12 = 102" \
96 "Print value-history\[2\] using explicit index \$2"
98 gdb_test
"print \$3" "\\\$13 = 103" \
99 "Print value-history\[3\] using explicit index \$3"
101 gdb_test
"print \$-3" "\\\$14 = 100" \
102 "Print (value-history\[MAX\] - 3) using implicit index \$"
104 gdb_test
"print \$1 + 3" "\\\$15 = 104" \
105 "Use value-history element in arithmetic expression"
108 # Start with a fresh gdb.
112 gdb_reinitialize_dir $srcdir
/$subdir
114 send_gdb
"set print sevenbit-strings\n" ; gdb_expect -re ".*$gdb_prompt $"
117 test_convenience_variables