Update copyright year in gdb/gdbserver/gdbreplay version output.
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.base / gdbvars.exp
CommitLineData
0b302171 1# Copyright (C) 1992, 1997, 2007-2012 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
c906108c 18
cab0c772
UW
19set testfile "gdbvars"
20set srcfile ${testfile}.c
21set binfile ${objdir}/${subdir}/${testfile}
22
23if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
24 untested gdbvars.exp
25 return -1
26}
27
c906108c
SS
28proc test_convenience_variables {} {
29 global gdb_prompt
30
27d3a1a2 31 gdb_test_no_output "set \$foo = 101" \
c906108c
SS
32 "Set a new convenience variable"
33
34 gdb_test "print \$foo" " = 101" \
35 "Print contents of new convenience variable"
36
27d3a1a2 37 gdb_test_no_output "set \$foo = 301" \
c906108c
SS
38 "Set convenience variable to a new value"
39
40 gdb_test "print \$foo" " = 301" \
41 "Print new contents of convenience variable"
42
27d3a1a2 43 gdb_test_no_output "set \$_ = 11" \
c906108c
SS
44 "Set convenience variable \$_"
45
46 gdb_test "print \$_" " = 11" \
47 "Print contents of convenience variable \$_"
48
49 gdb_test "print \$foo + 10" " = 311" \
50 "Use convenience variable in arithmetic expression"
51
52 gdb_test "print (\$foo = 32) + 4" " = 36" \
53 "Use convenience variable assignment in arithmetic expression"
54
55 gdb_test "print \$bar" " = void" \
56 "Print contents of uninitialized convenience variable"
57}
58
59proc test_value_history {} {
60 global gdb_prompt
61
62 gdb_test "print 101" "\\\$1 = 101" \
63 "Set value-history\[1\] using \$1"
64
65 gdb_test "print 102" "\\\$2 = 102" \
66 "Set value-history\[2\] using \$2"
67
68 gdb_test "print 103" "\\\$3 = 103" \
69 "Set value-history\[3\] using \$3"
70
71 gdb_test "print \$\$" "\\\$4 = 102" \
72 "Print value-history\[MAX-1\] using inplicit index \$\$"
73
74 gdb_test "print \$\$" "\\\$5 = 103" \
75 "Print value-history\[MAX-1\] again using implicit index \$\$"
76
77 gdb_test "print \$" "\\\$6 = 103" \
78 "Print value-history\[MAX\] using implicit index \$"
79
80 gdb_test "print \$\$2" "\\\$7 = 102" \
81 "Print value-history\[MAX-2\] using explicit index \$\$2"
82
83 gdb_test "print \$0" "\\\$8 = 102" \
84 "Print value-history\[MAX\] using explicit index \$0"
85
a0b3c4fd 86 gdb_test "print 108" "\\\$9 = 108"
c906108c
SS
87
88 gdb_test "print \$\$0" "\\\$10 = 108" \
89 "Print value-history\[MAX\] using explicit index \$\$0"
90
91 gdb_test "print \$1" "\\\$11 = 101" \
92 "Print value-history\[1\] using explicit index \$1"
93
94 gdb_test "print \$2" "\\\$12 = 102" \
95 "Print value-history\[2\] using explicit index \$2"
96
97 gdb_test "print \$3" "\\\$13 = 103" \
98 "Print value-history\[3\] using explicit index \$3"
99
100 gdb_test "print \$-3" "\\\$14 = 100" \
101 "Print (value-history\[MAX\] - 3) using implicit index \$"
102
103 gdb_test "print \$1 + 3" "\\\$15 = 104" \
104 "Use value-history element in arithmetic expression"
105}
106
cab0c772
UW
107proc test_with_program {} {
108 global hex
27d3a1a2 109 gdb_test_no_output "set \$prog_var = p" \
cab0c772
UW
110 "Set a new convenience variable to a program variable"
111 gdb_test "print /x \$prog_var" " = $hex" \
112 "Print contents of new convenience variable of program variable"
113}
114
c906108c
SS
115# Start with a fresh gdb.
116
117gdb_exit
118gdb_start
119gdb_reinitialize_dir $srcdir/$subdir
cab0c772 120gdb_load ${binfile}
c906108c 121
a76e022a 122gdb_test_no_output "set print sevenbit-strings"
c906108c
SS
123
124test_value_history
125test_convenience_variables
cab0c772 126test_with_program
This page took 1.31468 seconds and 4 git commands to generate.