]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - gdb/testsuite/gdb.base/gdbvars.exp
Fix more cases of improper test names
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.base / gdbvars.exp
CommitLineData
618f726f 1# Copyright (C) 1992-2016 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
289f9037 19standard_testfile
cab0c772 20
5b362f04 21if {[prepare_for_testing "failed to prepare" $testfile $srcfile debug]} {
cab0c772
UW
22 return -1
23}
24
c906108c
SS
25proc test_convenience_variables {} {
26 global gdb_prompt
27
27d3a1a2 28 gdb_test_no_output "set \$foo = 101" \
c906108c
SS
29 "Set a new convenience variable"
30
31 gdb_test "print \$foo" " = 101" \
32 "Print contents of new convenience variable"
33
27d3a1a2 34 gdb_test_no_output "set \$foo = 301" \
c906108c
SS
35 "Set convenience variable to a new value"
36
37 gdb_test "print \$foo" " = 301" \
38 "Print new contents of convenience variable"
39
27d3a1a2 40 gdb_test_no_output "set \$_ = 11" \
c906108c
SS
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
a280dbd1
SDJ
56proc test_convenience_functions {} {
57 gdb_test "print \$_isvoid" " = <internal function _isvoid>" \
58 "Print internal function \$_isvoid"
59
60 gdb_test "print \$isvoid_foo" " = void" \
61 "Print void convenience variable"
62
63 gdb_test "print \$_isvoid (\$isvoid_foo)" " = 1" \
64 "Check whether void convenience variable is void"
65
66 gdb_test_no_output "set \$isvoid_foo = 1" \
67 "Set void convenience variable to 1"
68
69 gdb_test "print \$_isvoid (\$isvoid_foo)" " = 0" \
70 "Check whether non-void convenience variable is void"
71
72 # For the next test, we need the inferior to be running.
73 if { ![runto_main] } {
74 return -1
75 }
76
77 gdb_test "print \$_isvoid (foo_void ())" " = 1" \
78 "Check whether void function is void"
79
80 gdb_test "print \$_isvoid (foo_int ())" " = 0" \
81 "Check whether non-void function is void"
82}
83
c906108c
SS
84proc test_value_history {} {
85 global gdb_prompt
86
87 gdb_test "print 101" "\\\$1 = 101" \
88 "Set value-history\[1\] using \$1"
89
90 gdb_test "print 102" "\\\$2 = 102" \
91 "Set value-history\[2\] using \$2"
92
93 gdb_test "print 103" "\\\$3 = 103" \
94 "Set value-history\[3\] using \$3"
95
96 gdb_test "print \$\$" "\\\$4 = 102" \
97 "Print value-history\[MAX-1\] using inplicit index \$\$"
98
99 gdb_test "print \$\$" "\\\$5 = 103" \
100 "Print value-history\[MAX-1\] again using implicit index \$\$"
101
102 gdb_test "print \$" "\\\$6 = 103" \
103 "Print value-history\[MAX\] using implicit index \$"
104
105 gdb_test "print \$\$2" "\\\$7 = 102" \
106 "Print value-history\[MAX-2\] using explicit index \$\$2"
107
108 gdb_test "print \$0" "\\\$8 = 102" \
109 "Print value-history\[MAX\] using explicit index \$0"
110
a0b3c4fd 111 gdb_test "print 108" "\\\$9 = 108"
c906108c
SS
112
113 gdb_test "print \$\$0" "\\\$10 = 108" \
114 "Print value-history\[MAX\] using explicit index \$\$0"
115
116 gdb_test "print \$1" "\\\$11 = 101" \
117 "Print value-history\[1\] using explicit index \$1"
118
119 gdb_test "print \$2" "\\\$12 = 102" \
120 "Print value-history\[2\] using explicit index \$2"
121
122 gdb_test "print \$3" "\\\$13 = 103" \
123 "Print value-history\[3\] using explicit index \$3"
124
125 gdb_test "print \$-3" "\\\$14 = 100" \
126 "Print (value-history\[MAX\] - 3) using implicit index \$"
127
128 gdb_test "print \$1 + 3" "\\\$15 = 104" \
129 "Use value-history element in arithmetic expression"
130}
131
cab0c772
UW
132proc test_with_program {} {
133 global hex
27d3a1a2 134 gdb_test_no_output "set \$prog_var = p" \
cab0c772
UW
135 "Set a new convenience variable to a program variable"
136 gdb_test "print /x \$prog_var" " = $hex" \
137 "Print contents of new convenience variable of program variable"
138}
139
a76e022a 140gdb_test_no_output "set print sevenbit-strings"
c906108c
SS
141
142test_value_history
143test_convenience_variables
a280dbd1 144test_convenience_functions
cab0c772 145test_with_program