test suite update - gdb.base/[h-m]
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.base / gdbvars.exp
1 # Copyright (C) 1992-2013 Free Software Foundation, Inc.
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
5 # the Free Software Foundation; either version 3 of the License, or
6 # (at your option) any later version.
7 #
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.
12 #
13 # You should have received a copy of the GNU General Public License
14 # along with this program. If not, see <http://www.gnu.org/licenses/>.
15
16 # This file was written by Fred Fish. (fnf@cygnus.com)
17
18
19 standard_testfile
20
21 if {[prepare_for_testing $testfile.exp $testfile $srcfile debug]} {
22 untested $testfile.exp
23 return -1
24 }
25
26 proc test_convenience_variables {} {
27 global gdb_prompt
28
29 gdb_test_no_output "set \$foo = 101" \
30 "Set a new convenience variable"
31
32 gdb_test "print \$foo" " = 101" \
33 "Print contents of new convenience variable"
34
35 gdb_test_no_output "set \$foo = 301" \
36 "Set convenience variable to a new value"
37
38 gdb_test "print \$foo" " = 301" \
39 "Print new contents of convenience variable"
40
41 gdb_test_no_output "set \$_ = 11" \
42 "Set convenience variable \$_"
43
44 gdb_test "print \$_" " = 11" \
45 "Print contents of convenience variable \$_"
46
47 gdb_test "print \$foo + 10" " = 311" \
48 "Use convenience variable in arithmetic expression"
49
50 gdb_test "print (\$foo = 32) + 4" " = 36" \
51 "Use convenience variable assignment in arithmetic expression"
52
53 gdb_test "print \$bar" " = void" \
54 "Print contents of uninitialized convenience variable"
55 }
56
57 proc test_value_history {} {
58 global gdb_prompt
59
60 gdb_test "print 101" "\\\$1 = 101" \
61 "Set value-history\[1\] using \$1"
62
63 gdb_test "print 102" "\\\$2 = 102" \
64 "Set value-history\[2\] using \$2"
65
66 gdb_test "print 103" "\\\$3 = 103" \
67 "Set value-history\[3\] using \$3"
68
69 gdb_test "print \$\$" "\\\$4 = 102" \
70 "Print value-history\[MAX-1\] using inplicit index \$\$"
71
72 gdb_test "print \$\$" "\\\$5 = 103" \
73 "Print value-history\[MAX-1\] again using implicit index \$\$"
74
75 gdb_test "print \$" "\\\$6 = 103" \
76 "Print value-history\[MAX\] using implicit index \$"
77
78 gdb_test "print \$\$2" "\\\$7 = 102" \
79 "Print value-history\[MAX-2\] using explicit index \$\$2"
80
81 gdb_test "print \$0" "\\\$8 = 102" \
82 "Print value-history\[MAX\] using explicit index \$0"
83
84 gdb_test "print 108" "\\\$9 = 108"
85
86 gdb_test "print \$\$0" "\\\$10 = 108" \
87 "Print value-history\[MAX\] using explicit index \$\$0"
88
89 gdb_test "print \$1" "\\\$11 = 101" \
90 "Print value-history\[1\] using explicit index \$1"
91
92 gdb_test "print \$2" "\\\$12 = 102" \
93 "Print value-history\[2\] using explicit index \$2"
94
95 gdb_test "print \$3" "\\\$13 = 103" \
96 "Print value-history\[3\] using explicit index \$3"
97
98 gdb_test "print \$-3" "\\\$14 = 100" \
99 "Print (value-history\[MAX\] - 3) using implicit index \$"
100
101 gdb_test "print \$1 + 3" "\\\$15 = 104" \
102 "Use value-history element in arithmetic expression"
103 }
104
105 proc test_with_program {} {
106 global hex
107 gdb_test_no_output "set \$prog_var = p" \
108 "Set a new convenience variable to a program variable"
109 gdb_test "print /x \$prog_var" " = $hex" \
110 "Print contents of new convenience variable of program variable"
111 }
112
113 gdb_test_no_output "set print sevenbit-strings"
114
115 test_value_history
116 test_convenience_variables
117 test_with_program
This page took 0.076058 seconds and 4 git commands to generate.