1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
|
# Copyright (C) 1993, 1997 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
# Please email any bugs, comments, and/or additions to this file to:
# bug-gdb@prep.ai.mit.edu
# This file was written by Fred Fish. (fnf@cygnus.com)
if $tracelevel then {
strace $tracelevel
}
set prms_id 0
set bug_id 0
proc test_input_radix_2 {} {
gdb_test "set radix" \
"Input and output radices now set to decimal 10, hex a, octal 12." \
"set radix #1"
gdb_test "set input-radix 2" \
"Input radix now set to decimal 2, hex 2, octal 2."
gdb_test "show radix" \
"Input radix set to decimal 2, hex 2, octal 2.\r\nOutput radix set to decimal 10, hex a, octal 12." \
"show radix #1"
gdb_test "p 010" "8"
gdb_test "p 20." "20"
gdb_test "p (int) 20." "20"
gdb_test "p 0xf" "15"
gdb_test "p 10" "2"
gdb_test "p -101" "-5"
gdb_test "p 101" "5"
gdb_test "p 10101" "21"
gdb_test "p 4" "Invalid number \"4\"\\."
gdb_test "p -2" "Invalid number \"2\"\\."
}
# Test input radix 3 (an non-typical radix)
proc test_input_radix_3 {} {
gdb_test "set radix" \
"Input and output radices now set to decimal 10, hex a, octal 12." \
"set radix #2"
gdb_test "set input-radix 3" \
"Input radix now set to decimal 3, hex 3, octal 3."
gdb_test "show radix" \
"Input radix set to decimal 3, hex 3, octal 3.\r\nOutput radix set to decimal 10, hex a, octal 12." \
"show radix #2"
gdb_test "p 010" "8"
gdb_test "p 20." "20"
gdb_test "p (int) 20." "20"
gdb_test "p 0xf" "15"
gdb_test "p 10" "3"
gdb_test "p 0" "0"
gdb_test "p 1" "1"
gdb_test "p 2" "2"
gdb_test "p 10" "3"
gdb_test "p 20" "6"
gdb_test "p 100" "9"
gdb_test "p -100" "-9"
gdb_test "p 3" "Invalid number \"3\"."
gdb_test "p 30" "Invalid number \"30\"."
}
proc test_input_radix_8 {} {
gdb_test "set radix" \
"Input and output radices now set to decimal 10, hex a, octal 12." \
"set radix #3"
gdb_test "set input-radix 8" \
"Input radix now set to decimal 8, hex 8, octal 10."
gdb_test "show radix" \
"Input radix set to decimal 8, hex 8, octal 10.\r\nOutput radix set to decimal 10, hex a, octal 12." \
"set radix #3"
gdb_test "p 010" "8"
gdb_test "p 20." "20"
gdb_test "p (int) 20." "20"
gdb_test "p 0xf" "15"
gdb_test "p 10" "8"
gdb_test "p 20" "16"
gdb_test "p -20" "-16"
gdb_test "p 100" "64"
gdb_test "p 8" "Invalid number \"8\"."
gdb_test "p -9" "Invalid number \"9\"."
}
proc test_input_radix_10 {} {
gdb_test "set radix" \
"Input and output radices now set to decimal 10, hex a, octal 12." \
"set radix #4"
gdb_test "set input-radix 10" \
"Input radix now set to decimal 10, hex a, octal 12."
gdb_test "show radix" \
"Input and output radices set to decimal 10, hex a, octal 12." \
"show radix #4"
gdb_test "p 010" "8"
gdb_test "p 20." "20"
gdb_test "p (int) 20." "20"
gdb_test "p 0xf" "15"
gdb_test "p 10" "10"
gdb_test "p -12" "-12"
}
proc test_input_radix_16 {} {
gdb_test "set radix" \
"Input and output radices now set to decimal 10, hex a, octal 12." \
"set radix #5"
gdb_test "set input-radix 16" \
"Input radix now set to decimal 16, hex 10, octal 20."
gdb_test "show radix" \
"Input radix set to decimal 16, hex 10, octal 20.\r\nOutput radix set to decimal 10, hex a, octal 12." \
"show radix #5"
gdb_test "p 010" "8"
gdb_test "p 20." "20"
gdb_test "p (int) 20." "20"
gdb_test "p 0xf" "15"
gdb_test "p 10" "16"
gdb_test "p 100" "256"
}
proc test_output_radix_8 {} {
gdb_test "set radix" \
"Input and output radices now set to decimal 10, hex a, octal 12." \
"set radix #6"
gdb_test "set output-radix 8" \
"Output radix now set to decimal 8, hex 8, octal 10."
gdb_test "show radix" \
"Input radix set to decimal 10, hex a, octal 12.\r\nOutput radix set to decimal 8, hex 8, octal 10." \
"show radix #6"
gdb_test "p 010" "010"
# FIXME: If gdb can't handle float printing in different radices, it
# should at least warn once the first time that is attempted.
setup_xfail "*-*-*"
gdb_test "p 20." "24" "Float printing when output radix is 8"
gdb_test "p (int) 20." "24"
gdb_test "p 0xf" "17"
gdb_test "p 10" "12"
gdb_test "p 100" "144"
}
proc test_output_radix_10 {} {
gdb_test "set radix" \
"Input and output radices now set to decimal 10, hex a, octal 12." \
"set radix #7"
gdb_test "set output-radix 10" \
"Output radix now set to decimal 10, hex a, octal 12."
gdb_test "show radix" \
"Input and output radices set to decimal 10, hex a, octal 12." \
"show radix #7"
gdb_test "p 010" "8"
gdb_test "p 20." "20"
gdb_test "p (int) 20." "20"
gdb_test "p 0xf" "15"
gdb_test "p 10" "10"
gdb_test "p 100" "100"
}
proc test_output_radix_16 {} {
gdb_test "set radix" \
"Input and output radices now set to decimal 10, hex a, octal 12." \
"set radix #8"
gdb_test "set output-radix 16" \
"Output radix now set to decimal 16, hex 10, octal 20."
gdb_test "show radix" \
"Input radix set to decimal 10, hex a, octal 12.\r\nOutput radix set to decimal 16, hex 10, octal 20." \
"show radix #8"
gdb_test "p 010" "8"
# FIXME: If gdb can't handle float printing in different radices, it
# should at least warn once the first time that is attempted.
setup_xfail "*-*-*"
gdb_test "p 20." "14" "Float printing when output radix is 16"
gdb_test "p (int) 20." "14"
gdb_test "p 0xf" "f"
gdb_test "p 10" "a"
gdb_test "p 100" "64"
}
# Start with a fresh gdb.
gdb_exit
gdb_start
test_input_radix_2
test_input_radix_3
test_input_radix_8
test_input_radix_10
test_input_radix_16
test_output_radix_8
test_output_radix_10
test_output_radix_16
|