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