]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - gdb/testsuite/gdb.base/gdbvars.exp
* config/sh/tm-sh.h (BELIEVE_PCC_PROMOTION): Define, so that
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.base / gdbvars.exp
CommitLineData
f1c9e446
JL
1# Copyright (C) 1992 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 2 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, write to the Free Software
787f6220 15# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
f1c9e446
JL
16
17# Please email any bugs, comments, and/or additions to this file to:
18# bug-gdb@prep.ai.mit.edu
19
20# This file was written by Fred Fish. (fnf@cygnus.com)
21
22if $tracelevel then {
23 strace $tracelevel
24}
25
26set prms_id 0
27set bug_id 0
28
29proc test_convenience_variables {} {
30 global prompt
31
787f6220 32 gdb_test "set \$foo = 101" "" \
f1c9e446
JL
33 "Set a new convenience variable"
34
35 gdb_test "print \$foo" " = 101" \
36 "Print contents of new convenience variable"
37
787f6220 38 gdb_test "set \$foo = 301" "" \
f1c9e446
JL
39 "Set convenience variable to a new value"
40
41 gdb_test "print \$foo" " = 301" \
42 "Print new contents of convenience variable"
43
787f6220 44 gdb_test "set \$_ = 11" "" \
f1c9e446
JL
45 "Set convenience variable \$_"
46
47 gdb_test "print \$_" " = 11" \
48 "Print contents of convenience variable \$_"
49
50 gdb_test "print \$foo + 10" " = 311" \
51 "Use convenience variable in arithmetic expression"
52
53 gdb_test "print (\$foo = 32) + 4" " = 36" \
54 "Use convenience variable assignment in arithmetic expression"
55
56 gdb_test "print \$bar" " = void" \
57 "Print contents of uninitialized convenience variable"
58}
59
60proc test_value_history {} {
61 global prompt
62
63 gdb_test "print 101" "\\\$1 = 101" \
64 "Set value-history\[1\] using \$1"
65
66 gdb_test "print 102" "\\\$2 = 102" \
67 "Set value-history\[2\] using \$2"
68
69 gdb_test "print 103" "\\\$3 = 103" \
70 "Set value-history\[3\] using \$3"
71
72 gdb_test "print \$\$" "\\\$4 = 102" \
73 "Print value-history\[MAX-1\] using inplicit index \$\$"
74
75 gdb_test "print \$\$" "\\\$5 = 103" \
76 "Print value-history\[MAX-1\] again using implicit index \$\$"
77
78 gdb_test "print \$" "\\\$6 = 103" \
79 "Print value-history\[MAX\] using implicit index \$"
80
81 gdb_test "print \$\$2" "\\\$7 = 102" \
82 "Print value-history\[MAX-2\] using explicit index \$\$2"
83
84 gdb_test "print \$0" "\\\$8 = 102" \
85 "Print value-history\[MAX\] using explicit index \$0"
86
87 gdb_test "print 108" "\\\$9 = 108" ""
88
89 gdb_test "print \$\$0" "\\\$10 = 108" \
90 "Print value-history\[MAX\] using explicit index \$\$0"
91
92 gdb_test "print \$1" "\\\$11 = 101" \
93 "Print value-history\[1\] using explicit index \$1"
94
95 gdb_test "print \$2" "\\\$12 = 102" \
96 "Print value-history\[2\] using explicit index \$2"
97
98 gdb_test "print \$3" "\\\$13 = 103" \
99 "Print value-history\[3\] using explicit index \$3"
100
101 gdb_test "print \$-3" "\\\$14 = 100" \
102 "Print (value-history\[MAX\] - 3) using implicit index \$"
103
104 gdb_test "print \$1 + 3" "\\\$15 = 104" \
105 "Use value-history element in arithmetic expression"
106}
107
108# Start with a fresh gdb.
109
110gdb_exit
111gdb_start
112gdb_reinitialize_dir $srcdir/$subdir
113
787f6220 114send_gdb "set print sevenbit-strings\n" ; expect -re ".*$prompt $"
f1c9e446
JL
115
116test_value_history
117test_convenience_variables