2009-07-01 Tristan Gingold <gingold@adacore.com>
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.base / gdbvars.exp
CommitLineData
0fb0cc75 1# Copyright (C) 1992, 1997, 2007, 2008, 2009 Free Software Foundation, Inc.
c906108c
SS
2
3# This program is free software; you can redistribute it and/or modify
4# it under the terms of the GNU General Public License as published by
e22f8b7c 5# the Free Software Foundation; either version 3 of the License, or
c906108c 6# (at your option) any later version.
e22f8b7c 7#
c906108c
SS
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.
e22f8b7c 12#
c906108c 13# You should have received a copy of the GNU General Public License
e22f8b7c 14# along with this program. If not, see <http://www.gnu.org/licenses/>.
c906108c 15
c906108c
SS
16# This file was written by Fred Fish. (fnf@cygnus.com)
17
18if $tracelevel then {
19 strace $tracelevel
20}
21
22set prms_id 0
23set bug_id 0
24
25proc test_convenience_variables {} {
26 global gdb_prompt
27
28 gdb_test "set \$foo = 101" "" \
29 "Set a new convenience variable"
30
31 gdb_test "print \$foo" " = 101" \
32 "Print contents of new convenience variable"
33
34 gdb_test "set \$foo = 301" "" \
35 "Set convenience variable to a new value"
36
37 gdb_test "print \$foo" " = 301" \
38 "Print new contents of convenience variable"
39
40 gdb_test "set \$_ = 11" "" \
41 "Set convenience variable \$_"
42
43 gdb_test "print \$_" " = 11" \
44 "Print contents of convenience variable \$_"
45
46 gdb_test "print \$foo + 10" " = 311" \
47 "Use convenience variable in arithmetic expression"
48
49 gdb_test "print (\$foo = 32) + 4" " = 36" \
50 "Use convenience variable assignment in arithmetic expression"
51
52 gdb_test "print \$bar" " = void" \
53 "Print contents of uninitialized convenience variable"
54}
55
56proc test_value_history {} {
57 global gdb_prompt
58
59 gdb_test "print 101" "\\\$1 = 101" \
60 "Set value-history\[1\] using \$1"
61
62 gdb_test "print 102" "\\\$2 = 102" \
63 "Set value-history\[2\] using \$2"
64
65 gdb_test "print 103" "\\\$3 = 103" \
66 "Set value-history\[3\] using \$3"
67
68 gdb_test "print \$\$" "\\\$4 = 102" \
69 "Print value-history\[MAX-1\] using inplicit index \$\$"
70
71 gdb_test "print \$\$" "\\\$5 = 103" \
72 "Print value-history\[MAX-1\] again using implicit index \$\$"
73
74 gdb_test "print \$" "\\\$6 = 103" \
75 "Print value-history\[MAX\] using implicit index \$"
76
77 gdb_test "print \$\$2" "\\\$7 = 102" \
78 "Print value-history\[MAX-2\] using explicit index \$\$2"
79
80 gdb_test "print \$0" "\\\$8 = 102" \
81 "Print value-history\[MAX\] using explicit index \$0"
82
a0b3c4fd 83 gdb_test "print 108" "\\\$9 = 108"
c906108c
SS
84
85 gdb_test "print \$\$0" "\\\$10 = 108" \
86 "Print value-history\[MAX\] using explicit index \$\$0"
87
88 gdb_test "print \$1" "\\\$11 = 101" \
89 "Print value-history\[1\] using explicit index \$1"
90
91 gdb_test "print \$2" "\\\$12 = 102" \
92 "Print value-history\[2\] using explicit index \$2"
93
94 gdb_test "print \$3" "\\\$13 = 103" \
95 "Print value-history\[3\] using explicit index \$3"
96
97 gdb_test "print \$-3" "\\\$14 = 100" \
98 "Print (value-history\[MAX\] - 3) using implicit index \$"
99
100 gdb_test "print \$1 + 3" "\\\$15 = 104" \
101 "Use value-history element in arithmetic expression"
102}
103
104# Start with a fresh gdb.
105
106gdb_exit
107gdb_start
108gdb_reinitialize_dir $srcdir/$subdir
109
110send_gdb "set print sevenbit-strings\n" ; gdb_expect -re ".*$gdb_prompt $"
111
112test_value_history
113test_convenience_variables
This page took 0.931789 seconds and 4 git commands to generate.