]>
Commit | Line | Data |
---|---|---|
7a292a7a | 1 | # Tests for reference types with short type variables in GDB. |
618f726f | 2 | # Copyright 1998-2016 Free Software Foundation, Inc. |
c906108c SS |
3 | |
4 | # This program is free software; you can redistribute it and/or modify | |
5 | # it under the terms of the GNU General Public License as published by | |
e22f8b7c | 6 | # the Free Software Foundation; either version 3 of the License, or |
c906108c | 7 | # (at your option) any later version. |
e22f8b7c | 8 | # |
c906108c SS |
9 | # This program is distributed in the hope that it will be useful, |
10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
12 | # GNU General Public License for more details. | |
e22f8b7c | 13 | # |
c906108c | 14 | # You should have received a copy of the GNU General Public License |
e22f8b7c | 15 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
c906108c | 16 | |
c906108c SS |
17 | # written by Elena Zannoni (ezannoni@cygnus.com) |
18 | ||
c906108c SS |
19 | # |
20 | # test running programs | |
21 | # | |
c906108c | 22 | |
d4f3574e SS |
23 | if { [skip_cplus_tests] } { continue } |
24 | ||
f5f3a911 | 25 | standard_testfile .cc |
c906108c | 26 | |
f5f3a911 TT |
27 | if {[prepare_for_testing $testfile.exp $testfile $srcfile {debug c++}]} { |
28 | return -1 | |
c906108c SS |
29 | } |
30 | ||
c906108c SS |
31 | # |
32 | # set it up at a breakpoint so we can play with the variable values | |
33 | # | |
34 | if ![runto_main] then { | |
35 | perror "couldn't run to breakpoint" | |
36 | continue | |
37 | } | |
38 | ||
b6c11a24 MC |
39 | if ![runto 'marker1'] then { |
40 | perror "couldn't run to marker1" | |
c906108c SS |
41 | continue |
42 | } | |
43 | ||
b6c11a24 MC |
44 | gdb_test "up" ".*main.*" "up from marker1 1" |
45 | ||
46 | proc gdb_start_again {} { | |
47 | global srcdir | |
48 | global subdir | |
49 | global binfile | |
50 | global gdb_prompt | |
51 | global decimal | |
52 | ||
53 | gdb_start | |
54 | gdb_reinitialize_dir $srcdir/$subdir | |
55 | gdb_load ${binfile} | |
56 | ||
b6c11a24 MC |
57 | # |
58 | # set it up at a breakpoint so we can play with the variable values | |
59 | # | |
60 | if ![runto_main] then { | |
61 | perror "couldn't run to breakpoint" | |
62 | continue | |
c906108c | 63 | } |
c906108c | 64 | |
b6c11a24 MC |
65 | if ![runto 'marker1'] then { |
66 | perror "couldn't run to marker1" | |
67 | continue | |
68 | } | |
c906108c | 69 | |
b6c11a24 MC |
70 | gdb_test "up" ".*main.*" "up from marker1 2" |
71 | } | |
c906108c SS |
72 | |
73 | ||
f8d3bf8f MS |
74 | gdb_test "print s" ".\[0-9\]* = -1" "print value of s" |
75 | gdb_test "ptype s" "type = short" | |
c906108c | 76 | |
f8d3bf8f MS |
77 | gdb_test "print *ps" ".\[0-9\]* = -1" "print value of ps" |
78 | gdb_test "ptype ps" "type = short \\*" | |
c906108c | 79 | |
f8d3bf8f MS |
80 | gdb_test "print as\[0\]" ".\[0-9\]* = 0" "print value of as\[0\]" |
81 | gdb_test_multiple "ptype as" "ptype as" { | |
c906108c | 82 | -re "type = short \\\[4\\\].*$gdb_prompt $" { pass "ptype as" } |
7a292a7a | 83 | -re "type = short int \\\[4\\\].*$gdb_prompt $" { pass "ptype as" } |
c906108c SS |
84 | } |
85 | ||
f8d3bf8f MS |
86 | gdb_test "print as\[1\]" ".\[0-9\]* = 1" "print value of as\[1\]" |
87 | gdb_test "print as\[2\]" ".\[0-9\]* = 2" "print value of as\[2\]" | |
88 | gdb_test "print as\[3\]" ".\[0-9\]* = 3" "print value of as\[3\]" | |
89 | ||
90 | gdb_test_multiple "print rs" "print value of rs" { | |
c906108c SS |
91 | -re ".\[0-9\]* = \\(short &\\) @$hex: -1.*$gdb_prompt $" { |
92 | pass "print value of rs" | |
7a292a7a SS |
93 | } |
94 | -re ".\[0-9\]* = \\(short int &\\) @$hex: -1.*$gdb_prompt $" { | |
95 | pass "print value of rs" | |
96 | } | |
c906108c | 97 | eof { fail "print rs ($GDB dumped core) (FIXME)" ; gdb_start_again ; } |
f8d3bf8f | 98 | } |
c906108c | 99 | |
f8d3bf8f | 100 | gdb_test_multiple "ptype rs" "ptype rs" { |
c906108c | 101 | -re "type = short &.*$gdb_prompt $" { pass "ptype rs" } |
7a292a7a | 102 | -re "type = short int &.*$gdb_prompt $" { pass "ptype rs" } |
c906108c SS |
103 | } |
104 | ||
f8d3bf8f | 105 | gdb_test "print *rps" ".\[0-9\]* = -1" "print value of *rps" |
c906108c | 106 | |
e1c34c5d PM |
107 | # GDB had a bug about dereferencing a pointer type |
108 | # that would lead to wrong results | |
109 | # if we try to examine memory at pointer value. | |
110 | ||
111 | gdb_test "x /hd rps" "$hex:\[ \t\]*-1" "examine value at rps" | |
c906108c | 112 | |
f8d3bf8f | 113 | gdb_test_multiple "ptype rps" "ptype rps" { |
c906108c | 114 | -re "type = short \\*&.*$gdb_prompt $" { pass "ptype rps" } |
7a292a7a | 115 | -re "type = short int \\*&.*$gdb_prompt $" { pass "ptype rps" } |
c906108c SS |
116 | } |
117 | ||
118 | ||
f8d3bf8f | 119 | gdb_test "print ras\[0\]" ".\[0-9\]* = 0" "print value of ras\[0\]" |
c906108c | 120 | |
f8d3bf8f | 121 | gdb_test_multiple "ptype ras" "ptype ras" { |
c906108c | 122 | -re "type = short \\\(&\\\)\\\[4\\\].*$gdb_prompt $" { pass "ptype ras" } |
7a292a7a | 123 | -re "type = short int \\\(&\\\)\\\[4\\\].*$gdb_prompt $" { pass "ptype ras" } |
c906108c SS |
124 | } |
125 | ||
f8d3bf8f MS |
126 | gdb_test "print ras\[1\]" ".\[0-9\]* = 1" "print value of ras\[1\]" |
127 | gdb_test "print ras\[2\]" ".\[0-9\]* = 2" "print value of ras\[2\]" | |
128 | gdb_test "print ras\[3\]" ".\[0-9\]* = 3" "print value of ras\[3\]" | |
a0b3c4fd JM |
129 | |
130 | ||
b6c11a24 MC |
131 | if ![runto 'f'] then { |
132 | perror "couldn't run to f" | |
133 | continue | |
134 | } | |
a0b3c4fd | 135 | |
b6c11a24 | 136 | gdb_test "up" ".main2.*" "up from f" |
a0b3c4fd | 137 | |
f8d3bf8f MS |
138 | gdb_test "print C" ".\[0-9\]* = 65 \'A\'" "print value of C" |
139 | gdb_test "ptype C" "type = char" | |
a0b3c4fd | 140 | |
f8d3bf8f MS |
141 | gdb_test "print UC" ".\[0-9\]* = 21 '\.025'" "print value of UC" |
142 | gdb_test "ptype UC" "type = unsigned char" | |
a0b3c4fd | 143 | |
f8d3bf8f MS |
144 | gdb_test "print S" ".\[0-9\]* = -14" "print value of S" |
145 | gdb_test "ptype S" "type = short.*" | |
a0b3c4fd | 146 | |
f8d3bf8f MS |
147 | gdb_test "print US" ".\[0-9\]* = 7" "print value of US" |
148 | gdb_test_multiple "ptype US" "ptype US" { | |
a0b3c4fd JM |
149 | -re "type = unsigned short.*$gdb_prompt $" { pass "ptype US" } |
150 | -re "type = short unsigned.*$gdb_prompt $" { pass "ptype US" } | |
a0b3c4fd JM |
151 | } |
152 | ||
f8d3bf8f MS |
153 | gdb_test "print I" ".\[0-9\]* = 102" "print value of I" |
154 | gdb_test "ptype I" "type = int" | |
a0b3c4fd | 155 | |
f8d3bf8f MS |
156 | gdb_test "print UI" ".\[0-9\]* = 1002" "print value of UI" |
157 | gdb_test "ptype UI" "type = unsigned int" | |
a0b3c4fd | 158 | |
f8d3bf8f MS |
159 | gdb_test "print L" ".\[0-9\]* = -234" "print value of L" |
160 | gdb_test "ptype L" "type = long.*" | |
a0b3c4fd | 161 | |
f8d3bf8f MS |
162 | gdb_test "print UL" ".\[0-9\]* = 234" "print value of UL" |
163 | gdb_test_multiple "ptype UL" "ptype UL" { | |
a0b3c4fd JM |
164 | -re "type = unsigned long.*$gdb_prompt $" { pass "ptype UL" } |
165 | -re "type = long unsigned.*$gdb_prompt $" { pass "ptype UL" } | |
a0b3c4fd JM |
166 | } |
167 | ||
f8d3bf8f MS |
168 | gdb_test "print F" ".\[0-9\]* = 1.2\[0-9\]*e\\+0?10.*" \ |
169 | "print value of F" | |
a0b3c4fd | 170 | |
f8d3bf8f | 171 | gdb_test "ptype F" "type = float.*" |
a0b3c4fd | 172 | |
f8d3bf8f MS |
173 | gdb_test "print D" ".\[0-9\]* = -1.375e-123.*" \ |
174 | "print value of D" | |
a0b3c4fd | 175 | |
f8d3bf8f | 176 | gdb_test "ptype D" "type = double.*" |
a0b3c4fd JM |
177 | |
178 | ||
179 | # | |
180 | # test reference types | |
181 | # | |
182 | ||
f8d3bf8f | 183 | gdb_test "ptype rC" "type = char &" |
a0b3c4fd | 184 | |
f8d3bf8f | 185 | gdb_test "ptype rUC" "type = unsigned char &" |
a0b3c4fd | 186 | |
f8d3bf8f | 187 | gdb_test_multiple "ptype rS" "ptype rS" { |
a0b3c4fd JM |
188 | -re "type = short &.*$gdb_prompt $" { pass "ptype rS" } |
189 | -re "type = short int &.*$gdb_prompt $" { pass "ptype rS" } | |
a0b3c4fd JM |
190 | } |
191 | ||
f8d3bf8f | 192 | gdb_test_multiple "ptype rUS" "ptype rUS" { |
a0b3c4fd JM |
193 | -re "type = unsigned short &.*$gdb_prompt $" { pass "ptype rUS" } |
194 | -re "type = short unsigned int &.*$gdb_prompt $" { pass "ptype rUS" } | |
a0b3c4fd JM |
195 | } |
196 | ||
f8d3bf8f | 197 | gdb_test "ptype rI" "type = int &" |
a0b3c4fd | 198 | |
f8d3bf8f | 199 | gdb_test "ptype rUI" "type = unsigned int &" |
a0b3c4fd | 200 | |
f8d3bf8f | 201 | gdb_test_multiple "ptype rL" "ptype rL" { |
a0b3c4fd JM |
202 | -re "type = long &.*$gdb_prompt $" { pass "ptype rL" } |
203 | -re "type = long int &.*$gdb_prompt $" { pass "ptype rL" } | |
a0b3c4fd JM |
204 | } |
205 | ||
f8d3bf8f | 206 | gdb_test_multiple "ptype rUL" "ptype rUL" { |
a0b3c4fd JM |
207 | -re "type = unsigned long &.*$gdb_prompt $" { pass "ptype rUL" } |
208 | -re "type = long unsigned int &.*$gdb_prompt $" { pass "ptype rUL" } | |
a0b3c4fd JM |
209 | } |
210 | ||
f8d3bf8f | 211 | gdb_test "ptype rF" "type = float &" |
a0b3c4fd | 212 | |
f8d3bf8f | 213 | gdb_test "ptype rD" "type = double &" |
a0b3c4fd | 214 | |
f8d3bf8f MS |
215 | gdb_test "print rC" ".\[0-9\]* = \\(char &\\) @$hex: 65 \'A\'" \ |
216 | "print value of rC" | |
a0b3c4fd | 217 | |
f8d3bf8f MS |
218 | gdb_test "print rUC" \ |
219 | ".\[0-9\]* = \\(unsigned char &\\) @$hex: 21 \'.025\'" \ | |
b8e8282f | 220 | "print value of rUC" |
a0b3c4fd | 221 | |
f8d3bf8f | 222 | gdb_test_multiple "print rS" "print value of rS" { |
a0b3c4fd JM |
223 | -re ".\[0-9\]* = \\(short &\\) @$hex: -14.*$gdb_prompt $" { |
224 | pass "print value of rS" | |
225 | } | |
226 | -re ".\[0-9\]* = \\(short int &\\) @$hex: -14.*$gdb_prompt $" { | |
227 | pass "print value of rS" | |
228 | } | |
f8d3bf8f | 229 | } |
a0b3c4fd | 230 | |
f8d3bf8f | 231 | gdb_test_multiple "print rUS" "print value of rUS" { |
a0b3c4fd JM |
232 | -re ".\[0-9\]* = \\(unsigned short &\\) @$hex: 7.*$gdb_prompt $" { |
233 | pass "print value of rUS" | |
234 | } | |
235 | -re ".\[0-9\]* = \\(short unsigned int &\\) @$hex: 7.*$gdb_prompt $" { | |
236 | pass "print value of rUS" | |
237 | } | |
f8d3bf8f | 238 | } |
a0b3c4fd | 239 | |
f8d3bf8f | 240 | gdb_test "print rI" ".\[0-9\]* = \\(int &\\) @$hex: 102" \ |
b8e8282f | 241 | "print value of rI" |
a0b3c4fd | 242 | |
3e0ca3a5 | 243 | gdb_test "print rUI" \ |
f8d3bf8f | 244 | ".\[0-9\]* = \\(unsigned int &\\) @$hex: 1002" \ |
b8e8282f | 245 | "print value of UI" |
a0b3c4fd | 246 | |
f8d3bf8f | 247 | gdb_test_multiple "print rL" "print value of rL" { |
a0b3c4fd JM |
248 | -re ".\[0-9\]* = \\(long &\\) @$hex: -234.*$gdb_prompt $" { |
249 | pass "print value of rL" | |
250 | } | |
251 | -re ".\[0-9\]* = \\(long int &\\) @$hex: -234.*$gdb_prompt $" { | |
252 | pass "print value of rL" | |
253 | } | |
f8d3bf8f | 254 | } |
a0b3c4fd | 255 | |
f8d3bf8f | 256 | gdb_test_multiple "print rUL" "print value of rUL" { |
a0b3c4fd JM |
257 | -re ".\[0-9\]* = \\(unsigned long &\\) @$hex: 234.*$gdb_prompt $" { |
258 | pass "print value of rUL" | |
259 | } | |
260 | -re ".\[0-9\]* = \\(long unsigned int &\\) @$hex: 234.*$gdb_prompt $" { | |
261 | pass "print value of rUL" | |
262 | } | |
f8d3bf8f MS |
263 | } |
264 | ||
265 | gdb_test "print rF" \ | |
266 | ".\[0-9\]* = \\(float &\\) @$hex: 1.2\[0-9\]*e\\+0?10.*" \ | |
267 | "print value of rF" | |
268 | ||
269 | gdb_test "print rD" \ | |
270 | ".\[0-9\]* = \\(double &\\) @$hex: -1.375e-123.*" \ | |
271 | "print value of rD" | |
a0b3c4fd | 272 |