* gdb.cp/mb-inline.exp: Do "info break" after setting multi-location
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.cp / ref-types.exp
... / ...
CommitLineData
1# Tests for reference types with short type variables in GDB.
2# Copyright 1998-2000, 2004, 2007-2012 Free Software Foundation, Inc.
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
6# the Free Software Foundation; either version 3 of the License, or
7# (at your option) any later version.
8#
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.
13#
14# You should have received a copy of the GNU General Public License
15# along with this program. If not, see <http://www.gnu.org/licenses/>.
16
17# written by Elena Zannoni (ezannoni@cygnus.com)
18
19#
20# test running programs
21#
22
23if { [skip_cplus_tests] } { continue }
24
25standard_testfile .cc
26
27if {[prepare_for_testing $testfile.exp $testfile $srcfile {debug c++}]} {
28 return -1
29}
30
31#
32# set it up at a breakpoint so we can play with the variable values
33#
34if ![runto_main] then {
35 perror "couldn't run to breakpoint"
36 continue
37}
38
39if ![runto 'marker1'] then {
40 perror "couldn't run to marker1"
41 continue
42}
43
44gdb_test "up" ".*main.*" "up from marker1 1"
45
46proc 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
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
63 }
64
65 if ![runto 'marker1'] then {
66 perror "couldn't run to marker1"
67 continue
68 }
69
70 gdb_test "up" ".*main.*" "up from marker1 2"
71}
72
73
74gdb_test "print s" ".\[0-9\]* = -1" "print value of s"
75gdb_test "ptype s" "type = short"
76
77gdb_test "print *ps" ".\[0-9\]* = -1" "print value of ps"
78gdb_test "ptype ps" "type = short \\*"
79
80gdb_test "print as\[0\]" ".\[0-9\]* = 0" "print value of as\[0\]"
81gdb_test_multiple "ptype as" "ptype as" {
82 -re "type = short \\\[4\\\].*$gdb_prompt $" { pass "ptype as" }
83 -re "type = short int \\\[4\\\].*$gdb_prompt $" { pass "ptype as" }
84}
85
86gdb_test "print as\[1\]" ".\[0-9\]* = 1" "print value of as\[1\]"
87gdb_test "print as\[2\]" ".\[0-9\]* = 2" "print value of as\[2\]"
88gdb_test "print as\[3\]" ".\[0-9\]* = 3" "print value of as\[3\]"
89
90gdb_test_multiple "print rs" "print value of rs" {
91 -re ".\[0-9\]* = \\(short &\\) @$hex: -1.*$gdb_prompt $" {
92 pass "print value of rs"
93 }
94 -re ".\[0-9\]* = \\(short int &\\) @$hex: -1.*$gdb_prompt $" {
95 pass "print value of rs"
96 }
97 eof { fail "print rs ($GDB dumped core) (FIXME)" ; gdb_start_again ; }
98}
99
100gdb_test_multiple "ptype rs" "ptype rs" {
101 -re "type = short &.*$gdb_prompt $" { pass "ptype rs" }
102 -re "type = short int &.*$gdb_prompt $" { pass "ptype rs" }
103}
104
105gdb_test "print *rps" ".\[0-9\]* = -1" "print value of *rps"
106
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
111gdb_test "x /hd rps" "$hex:\[ \t\]*-1" "examine value at rps"
112
113gdb_test_multiple "ptype rps" "ptype rps" {
114 -re "type = short \\*&.*$gdb_prompt $" { pass "ptype rps" }
115 -re "type = short int \\*&.*$gdb_prompt $" { pass "ptype rps" }
116}
117
118
119gdb_test "print ras\[0\]" ".\[0-9\]* = 0" "print value of ras\[0\]"
120
121gdb_test_multiple "ptype ras" "ptype ras" {
122 -re "type = short \\\(&\\\)\\\[4\\\].*$gdb_prompt $" { pass "ptype ras" }
123 -re "type = short int \\\(&\\\)\\\[4\\\].*$gdb_prompt $" { pass "ptype ras" }
124}
125
126gdb_test "print ras\[1\]" ".\[0-9\]* = 1" "print value of ras\[1\]"
127gdb_test "print ras\[2\]" ".\[0-9\]* = 2" "print value of ras\[2\]"
128gdb_test "print ras\[3\]" ".\[0-9\]* = 3" "print value of ras\[3\]"
129
130
131if ![runto 'f'] then {
132 perror "couldn't run to f"
133 continue
134}
135
136gdb_test "up" ".main2.*" "up from f"
137
138gdb_test "print C" ".\[0-9\]* = 65 \'A\'" "print value of C"
139gdb_test "ptype C" "type = char"
140
141gdb_test "print UC" ".\[0-9\]* = 21 '\.025'" "print value of UC"
142gdb_test "ptype UC" "type = unsigned char"
143
144gdb_test "print S" ".\[0-9\]* = -14" "print value of S"
145gdb_test "ptype S" "type = short.*"
146
147gdb_test "print US" ".\[0-9\]* = 7" "print value of US"
148gdb_test_multiple "ptype US" "ptype US" {
149 -re "type = unsigned short.*$gdb_prompt $" { pass "ptype US" }
150 -re "type = short unsigned.*$gdb_prompt $" { pass "ptype US" }
151}
152
153gdb_test "print I" ".\[0-9\]* = 102" "print value of I"
154gdb_test "ptype I" "type = int"
155
156gdb_test "print UI" ".\[0-9\]* = 1002" "print value of UI"
157gdb_test "ptype UI" "type = unsigned int"
158
159gdb_test "print L" ".\[0-9\]* = -234" "print value of L"
160gdb_test "ptype L" "type = long.*"
161
162gdb_test "print UL" ".\[0-9\]* = 234" "print value of UL"
163gdb_test_multiple "ptype UL" "ptype UL" {
164 -re "type = unsigned long.*$gdb_prompt $" { pass "ptype UL" }
165 -re "type = long unsigned.*$gdb_prompt $" { pass "ptype UL" }
166}
167
168gdb_test "print F" ".\[0-9\]* = 1.2\[0-9\]*e\\+0?10.*" \
169 "print value of F"
170
171gdb_test "ptype F" "type = float.*"
172
173gdb_test "print D" ".\[0-9\]* = -1.375e-123.*" \
174 "print value of D"
175
176gdb_test "ptype D" "type = double.*"
177
178
179#
180# test reference types
181#
182
183gdb_test "ptype rC" "type = char &"
184
185gdb_test "ptype rUC" "type = unsigned char &"
186
187gdb_test_multiple "ptype rS" "ptype rS" {
188 -re "type = short &.*$gdb_prompt $" { pass "ptype rS" }
189 -re "type = short int &.*$gdb_prompt $" { pass "ptype rS" }
190}
191
192gdb_test_multiple "ptype rUS" "ptype rUS" {
193 -re "type = unsigned short &.*$gdb_prompt $" { pass "ptype rUS" }
194 -re "type = short unsigned int &.*$gdb_prompt $" { pass "ptype rUS" }
195}
196
197gdb_test "ptype rI" "type = int &"
198
199gdb_test "ptype rUI" "type = unsigned int &"
200
201gdb_test_multiple "ptype rL" "ptype rL" {
202 -re "type = long &.*$gdb_prompt $" { pass "ptype rL" }
203 -re "type = long int &.*$gdb_prompt $" { pass "ptype rL" }
204}
205
206gdb_test_multiple "ptype rUL" "ptype rUL" {
207 -re "type = unsigned long &.*$gdb_prompt $" { pass "ptype rUL" }
208 -re "type = long unsigned int &.*$gdb_prompt $" { pass "ptype rUL" }
209}
210
211gdb_test "ptype rF" "type = float &"
212
213gdb_test "ptype rD" "type = double &"
214
215gdb_test "print rC" ".\[0-9\]* = \\(char &\\) @$hex: 65 \'A\'" \
216 "print value of rC"
217
218gdb_test "print rUC" \
219 ".\[0-9\]* = \\(unsigned char &\\) @$hex: 21 \'.025\'" \
220 "print value of rUC"
221
222gdb_test_multiple "print rS" "print value of rS" {
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 }
229}
230
231gdb_test_multiple "print rUS" "print value of rUS" {
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 }
238}
239
240gdb_test "print rI" ".\[0-9\]* = \\(int &\\) @$hex: 102" \
241 "print value of rI"
242
243gdb_test "print rUI" \
244 ".\[0-9\]* = \\(unsigned int &\\) @$hex: 1002" \
245 "print value of UI"
246
247gdb_test_multiple "print rL" "print value of rL" {
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 }
254}
255
256gdb_test_multiple "print rUL" "print value of rUL" {
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 }
263}
264
265gdb_test "print rF" \
266 ".\[0-9\]* = \\(float &\\) @$hex: 1.2\[0-9\]*e\\+0?10.*" \
267 "print value of rF"
268
269gdb_test "print rD" \
270 ".\[0-9\]* = \\(double &\\) @$hex: -1.375e-123.*" \
271 "print value of rD"
272
This page took 0.023145 seconds and 4 git commands to generate.