1 # Copyright 1993, 1997 Free Software Foundation, Inc.
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.
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.
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
15 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17 # Please email any bugs, comments, and/or additions to this file to:
18 # bug-gdb@prep.ai.mit.edu
20 # This file was written by Fred Fish. (fnf@cygnus.com)
29 proc test_input_radix_2 {} {
30 gdb_test "set radix" \
31 "Input and output radices now set to decimal 10, hex a, octal 12." \
33 gdb_test "set input-radix 2" \
34 "Input radix now set to decimal 2, hex 2, octal 2."
35 gdb_test "show radix" \
36 "Input radix set to decimal 2, hex 2, octal 2.\r\nOutput radix set to decimal 10, hex a, octal 12." \
40 gdb_test "p (int) 20." "20"
43 gdb_test "p -101" "-5"
45 gdb_test "p 10101" "21"
46 gdb_test "p 4" "Invalid number \"4\"\\."
47 gdb_test "p -2" "Invalid number \"2\"\\."
50 # Test input radix 3 (an non-typical radix)
52 proc test_input_radix_3 {} {
53 gdb_test "set radix" \
54 "Input and output radices now set to decimal 10, hex a, octal 12." \
56 gdb_test "set input-radix 3" \
57 "Input radix now set to decimal 3, hex 3, octal 3."
58 gdb_test "show radix" \
59 "Input radix set to decimal 3, hex 3, octal 3.\r\nOutput radix set to decimal 10, hex a, octal 12." \
63 gdb_test "p (int) 20." "20"
72 gdb_test "p -100" "-9"
73 gdb_test "p 3" "Invalid number \"3\"."
74 gdb_test "p 30" "Invalid number \"30\"."
77 proc test_input_radix_8 {} {
78 gdb_test "set radix" \
79 "Input and output radices now set to decimal 10, hex a, octal 12." \
81 gdb_test "set input-radix 8" \
82 "Input radix now set to decimal 8, hex 8, octal 10."
83 gdb_test "show radix" \
84 "Input radix set to decimal 8, hex 8, octal 10.\r\nOutput radix set to decimal 10, hex a, octal 12." \
88 gdb_test "p (int) 20." "20"
92 gdb_test "p -20" "-16"
94 gdb_test "p 8" "Invalid number \"8\"."
95 gdb_test "p -9" "Invalid number \"9\"."
98 proc test_input_radix_10 {} {
99 gdb_test "set radix" \
100 "Input and output radices now set to decimal 10, hex a, octal 12." \
102 gdb_test "set input-radix 10" \
103 "Input radix now set to decimal 10, hex a, octal 12."
104 gdb_test "show radix" \
105 "Input and output radices set to decimal 10, hex a, octal 12." \
108 gdb_test "p 20." "20"
109 gdb_test "p (int) 20." "20"
110 gdb_test "p 0xf" "15"
112 gdb_test "p -12" "-12"
115 proc test_input_radix_16 {} {
116 gdb_test "set radix" \
117 "Input and output radices now set to decimal 10, hex a, octal 12." \
119 gdb_test "set input-radix 16" \
120 "Input radix now set to decimal 16, hex 10, octal 20."
121 gdb_test "show radix" \
122 "Input radix set to decimal 16, hex 10, octal 20.\r\nOutput radix set to decimal 10, hex a, octal 12." \
125 gdb_test "p 20." "20"
126 gdb_test "p (int) 20." "20"
127 gdb_test "p 0xf" "15"
129 gdb_test "p 100" "256"
132 proc test_output_radix_8 {} {
133 gdb_test "set radix" \
134 "Input and output radices now set to decimal 10, hex a, octal 12." \
136 gdb_test "set output-radix 8" \
137 "Output radix now set to decimal 8, hex 8, octal 10."
138 gdb_test "show radix" \
139 "Input radix set to decimal 10, hex a, octal 12.\r\nOutput radix set to decimal 8, hex 8, octal 10." \
141 gdb_test "p 010" "010"
142 # FIXME: If gdb can't handle float printing in different radices, it
143 # should at least warn once the first time that is attempted.
145 gdb_test "p 20." "24" "Float printing when output radix is 8"
146 gdb_test "p (int) 20." "24"
147 gdb_test "p 0xf" "17"
149 gdb_test "p 100" "144"
152 proc test_output_radix_10 {} {
153 gdb_test "set radix" \
154 "Input and output radices now set to decimal 10, hex a, octal 12." \
156 gdb_test "set output-radix 10" \
157 "Output radix now set to decimal 10, hex a, octal 12."
158 gdb_test "show radix" \
159 "Input and output radices set to decimal 10, hex a, octal 12." \
162 gdb_test "p 20." "20"
163 gdb_test "p (int) 20." "20"
164 gdb_test "p 0xf" "15"
166 gdb_test "p 100" "100"
169 proc test_output_radix_16 {} {
170 gdb_test "set radix" \
171 "Input and output radices now set to decimal 10, hex a, octal 12." \
173 gdb_test "set output-radix 16" \
174 "Output radix now set to decimal 16, hex 10, octal 20."
175 gdb_test "show radix" \
176 "Input radix set to decimal 10, hex a, octal 12.\r\nOutput radix set to decimal 16, hex 10, octal 20." \
179 # FIXME: If gdb can't handle float printing in different radices, it
180 # should at least warn once the first time that is attempted.
182 gdb_test "p 20." "14" "Float printing when output radix is 16"
183 gdb_test "p (int) 20." "14"
186 gdb_test "p 100" "64"
189 # Start with a fresh gdb.