ignore invalid DOF provider sections
[binutils-gdb.git] / gdb / testsuite / gdb.cp / ref-types.exp
blob61827ab8ce643830ca0d9293232c6bcd03044fd4
1 # Tests for reference types with short type variables in GDB.
2 # Copyright 1998-2015 Free Software Foundation, Inc.
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.
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.
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/>.
17 # written by Elena Zannoni (ezannoni@cygnus.com)
20 # test running programs
23 if { [skip_cplus_tests] } { continue }
25 standard_testfile .cc
27 if {[prepare_for_testing $testfile.exp $testfile $srcfile {debug c++}]} {
28 return -1
32 # set it up at a breakpoint so we can play with the variable values
34 if ![runto_main] then {
35 perror "couldn't run to breakpoint"
36 continue
39 if ![runto 'marker1'] then {
40 perror "couldn't run to marker1"
41 continue
44 gdb_test "up" ".*main.*" "up from marker1 1"
46 proc gdb_start_again {} {
47 global srcdir
48 global subdir
49 global binfile
50 global gdb_prompt
51 global decimal
53 gdb_start
54 gdb_reinitialize_dir $srcdir/$subdir
55 gdb_load ${binfile}
58 # set it up at a breakpoint so we can play with the variable values
60 if ![runto_main] then {
61 perror "couldn't run to breakpoint"
62 continue
65 if ![runto 'marker1'] then {
66 perror "couldn't run to marker1"
67 continue
70 gdb_test "up" ".*main.*" "up from marker1 2"
74 gdb_test "print s" ".\[0-9\]* = -1" "print value of s"
75 gdb_test "ptype s" "type = short"
77 gdb_test "print *ps" ".\[0-9\]* = -1" "print value of ps"
78 gdb_test "ptype ps" "type = short \\*"
80 gdb_test "print as\[0\]" ".\[0-9\]* = 0" "print value of as\[0\]"
81 gdb_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" }
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\]"
90 gdb_test_multiple "print rs" "print value of rs" {
91 -re ".\[0-9\]* = \\(short &\\) @$hex: -1.*$gdb_prompt $" {
92 pass "print value of rs"
94 -re ".\[0-9\]* = \\(short int &\\) @$hex: -1.*$gdb_prompt $" {
95 pass "print value of rs"
97 eof { fail "print rs ($GDB dumped core) (FIXME)" ; gdb_start_again ; }
100 gdb_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" }
105 gdb_test "print *rps" ".\[0-9\]* = -1" "print value of *rps"
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.
111 gdb_test "x /hd rps" "$hex:\[ \t\]*-1" "examine value at rps"
113 gdb_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" }
119 gdb_test "print ras\[0\]" ".\[0-9\]* = 0" "print value of ras\[0\]"
121 gdb_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" }
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\]"
131 if ![runto 'f'] then {
132 perror "couldn't run to f"
133 continue
136 gdb_test "up" ".main2.*" "up from f"
138 gdb_test "print C" ".\[0-9\]* = 65 \'A\'" "print value of C"
139 gdb_test "ptype C" "type = char"
141 gdb_test "print UC" ".\[0-9\]* = 21 '\.025'" "print value of UC"
142 gdb_test "ptype UC" "type = unsigned char"
144 gdb_test "print S" ".\[0-9\]* = -14" "print value of S"
145 gdb_test "ptype S" "type = short.*"
147 gdb_test "print US" ".\[0-9\]* = 7" "print value of US"
148 gdb_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" }
153 gdb_test "print I" ".\[0-9\]* = 102" "print value of I"
154 gdb_test "ptype I" "type = int"
156 gdb_test "print UI" ".\[0-9\]* = 1002" "print value of UI"
157 gdb_test "ptype UI" "type = unsigned int"
159 gdb_test "print L" ".\[0-9\]* = -234" "print value of L"
160 gdb_test "ptype L" "type = long.*"
162 gdb_test "print UL" ".\[0-9\]* = 234" "print value of UL"
163 gdb_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" }
168 gdb_test "print F" ".\[0-9\]* = 1.2\[0-9\]*e\\+0?10.*" \
169 "print value of F"
171 gdb_test "ptype F" "type = float.*"
173 gdb_test "print D" ".\[0-9\]* = -1.375e-123.*" \
174 "print value of D"
176 gdb_test "ptype D" "type = double.*"
180 # test reference types
183 gdb_test "ptype rC" "type = char &"
185 gdb_test "ptype rUC" "type = unsigned char &"
187 gdb_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" }
192 gdb_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" }
197 gdb_test "ptype rI" "type = int &"
199 gdb_test "ptype rUI" "type = unsigned int &"
201 gdb_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" }
206 gdb_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" }
211 gdb_test "ptype rF" "type = float &"
213 gdb_test "ptype rD" "type = double &"
215 gdb_test "print rC" ".\[0-9\]* = \\(char &\\) @$hex: 65 \'A\'" \
216 "print value of rC"
218 gdb_test "print rUC" \
219 ".\[0-9\]* = \\(unsigned char &\\) @$hex: 21 \'.025\'" \
220 "print value of rUC"
222 gdb_test_multiple "print rS" "print value of rS" {
223 -re ".\[0-9\]* = \\(short &\\) @$hex: -14.*$gdb_prompt $" {
224 pass "print value of rS"
226 -re ".\[0-9\]* = \\(short int &\\) @$hex: -14.*$gdb_prompt $" {
227 pass "print value of rS"
231 gdb_test_multiple "print rUS" "print value of rUS" {
232 -re ".\[0-9\]* = \\(unsigned short &\\) @$hex: 7.*$gdb_prompt $" {
233 pass "print value of rUS"
235 -re ".\[0-9\]* = \\(short unsigned int &\\) @$hex: 7.*$gdb_prompt $" {
236 pass "print value of rUS"
240 gdb_test "print rI" ".\[0-9\]* = \\(int &\\) @$hex: 102" \
241 "print value of rI"
243 gdb_test "print rUI" \
244 ".\[0-9\]* = \\(unsigned int &\\) @$hex: 1002" \
245 "print value of UI"
247 gdb_test_multiple "print rL" "print value of rL" {
248 -re ".\[0-9\]* = \\(long &\\) @$hex: -234.*$gdb_prompt $" {
249 pass "print value of rL"
251 -re ".\[0-9\]* = \\(long int &\\) @$hex: -234.*$gdb_prompt $" {
252 pass "print value of rL"
256 gdb_test_multiple "print rUL" "print value of rUL" {
257 -re ".\[0-9\]* = \\(unsigned long &\\) @$hex: 234.*$gdb_prompt $" {
258 pass "print value of rUL"
260 -re ".\[0-9\]* = \\(long unsigned int &\\) @$hex: 234.*$gdb_prompt $" {
261 pass "print value of rUL"
265 gdb_test "print rF" \
266 ".\[0-9\]* = \\(float &\\) @$hex: 1.2\[0-9\]*e\\+0?10.*" \
267 "print value of rF"
269 gdb_test "print rD" \
270 ".\[0-9\]* = \\(double &\\) @$hex: -1.375e-123.*" \
271 "print value of rD"