* gdb.cp/ctti.exp: Handle unsigned char type. Expect templates
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.cp / ctti.exp
1 # Copyright 1998, 1999, 2001, 2003, 2004 Free Software Foundation, Inc.
2
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.
7 #
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.
12 #
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.
16
17 # This file is part of the gdb testsuite
18 # file written by Elena Zannoni (ezannoni@cygnus.com)
19 # rewritten by Michael Chastain (mec.gnu@mindspring.com)
20 #
21 # source files cttiadd.cc, cttiadd1.cc, cttiadd2.cc, cttiadd3.cc
22
23 # Call to template instantiations.
24
25 if $tracelevel then {
26 strace $tracelevel
27 }
28
29 if { [skip_cplus_tests] } { continue }
30
31 set testfile "cttiadd"
32 set srcfile "${srcdir}/${subdir}/${testfile}.cc"
33 set srcfile1 "${srcdir}/${subdir}/${testfile}1.cc"
34 set srcfile2 "${srcdir}/${subdir}/${testfile}2.cc"
35 set srcfile3 "${srcdir}/${subdir}/${testfile}3.cc"
36 set objfile "${objdir}/${subdir}/${testfile}.o"
37 set objfile1 "${objdir}/${subdir}/${testfile}1.o"
38 set objfile2 "${objdir}/${subdir}/${testfile}2.o"
39 set objfile3 "${objdir}/${subdir}/${testfile}3.o"
40 set binfile "${objdir}/${subdir}/${testfile}"
41
42 if { [gdb_compile "${srcfile}" "${objfile}" object {debug c++}] != "" } {
43 gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
44 }
45
46 if { [gdb_compile "${srcfile1}" "${objfile1}" object {debug c++}] != "" } {
47 gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
48 }
49
50 if { [gdb_compile "${srcfile2}" "${objfile2}" object {debug c++}] != "" } {
51 gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
52 }
53
54 if { [gdb_compile "${srcfile3}" "${objfile3}" object {debug c++}] != "" } {
55 gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
56 }
57
58 if { [gdb_compile "${objfile} ${objfile1} ${objfile2} ${objfile3}" "${binfile}" executable {debug c++}] != "" } {
59 gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
60 }
61
62 if [get_compiler_info ${binfile} "c++"] {
63 return -1;
64 }
65
66 gdb_exit
67 gdb_start
68 gdb_reinitialize_dir $srcdir/$subdir
69 gdb_load ${binfile}
70
71 if ![runto_main] then {
72 perror "couldn't run to breakpoint"
73 continue
74 }
75
76 gdb_breakpoint [gdb_get_line_number "marker add1"]
77 gdb_continue_to_breakpoint "marker add1"
78
79 gdb_test "print c" "\\$\[0-9\]+ = 194 .*"
80 gdb_test "print f" "\\$\[0-9\]+ = 9"
81 gdb_test "print i" "\\$\[0-9\]+ = 4"
82
83 # TODO: this needs more work before actually deploying it.
84 # So bail out here.
85
86 if { [ test_compiler_info gcc-*] } then { continue }
87
88 gdb_test_multiple "print add<int>(2,2)" "print add<int>(2,2)" {
89 -re "\\$\[0-9\]+ = 4\r\n$gdb_prompt $" {
90 pass "print add<int>(2,2)"
91 }
92 -re "No symbol \"add<int>\" in current context.\r\n$gdb_prompt $" {
93 # TODO: kfail or xfail this
94 fail "print add<int>(2,2)"
95 }
96 }
97
98 # Note: 2.25 and 4.5 are exactly representable in IEEE-ish formats
99 gdb_test_multiple "print add<float>(2.25,2.25)" "print add<float>(2.25,2.25)" {
100 -re "\\$\[0-9\]+ = 4\\.5\r\n$gdb_prompt $" {
101 pass "print add<float>(2.25,2.25)"
102 }
103 -re "No symbol \"add<float>\" in current context.\r\n$gdb_prompt $" {
104 # TODO: kfail or xfail this
105 fail "print add<float>(2.25,2.25)"
106 }
107 }
108
109 gdb_test_multiple "print add<unsigned char>('A','A')" "print add<unsigned char>('A','A')" {
110 -re "\\$\[0-9\]+ = -126 .*\r\n$gdb_prompt $" {
111 pass "print add<unsigned char>('A','A')"
112 }
113 -re "No symbol \"add<unsigned char>\" in current context.\r\n$gdb_prompt $" {
114 # TODO: kfail or xfail this
115 fail "print add<unsigned char>('A','A')"
116 }
117 }
118
119 gdb_test_multiple "print add2<int>(2,2)" "print add2<int>(2,2)" {
120 -re "\\$\[0-9\]+ = 4\r\n$gdb_prompt $" {
121 pass "print add2<int>(2,2)"
122 }
123 -re "No symbol \"add2<int>\" in current context.\r\n$gdb_prompt $" {
124 # TODO: kfail or xfail this
125 fail "print add2<int>(2,2)"
126 }
127 }
128
129 gdb_test_multiple "print add2<float>(2.25,2.25)" "print add2<float>(2.25,2.25)" {
130 -re "\\$\[0-9\]+ = 4\\.5\r\n$gdb_prompt $" {
131 pass "print add2<float>(2.25,2.25)"
132 }
133 -re "No symbol \"add2<float>\" in current context.\r\n$gdb_prompt $" {
134 # TODO: kfail or xfail this
135 fail "print add2<float>(2.25,2.25)"
136 }
137 }
138
139 gdb_test_multiple "print add2<unsigned char>('A','A')" "print add2<unsigned char>('A','A')" {
140 -re "\\$\[0-9]+ = -126 .*$gdb_prompt $" {
141 pass "print add2<unsigned char>('A','A')"
142 }
143 -re "No symbol \"add2<unsigned char>\" in current context.\r\n$gdb_prompt $" {
144 # TODO: kfail or xfail this
145 fail "print add2<unsigned char>('A','A')"
146 }
147 }
148
149 gdb_test_multiple "print add3<int>(2,2)" "print add3<int>(2,2)" {
150 -re "\\$\[0-9\]+ = 4\r\n$gdb_prompt $" {
151 pass "print add3<int>(2,2)"
152 }
153 -re "No symbol \"add3<int>\" in current context.\r\n$gdb_prompt $" {
154 # TODO: kfail or xfail this
155 fail "print add3<int>(2,2)"
156 }
157 }
158
159 gdb_test_multiple "print add3<float>(2.25,2.25)" "print add3<float>(2.25,2.25)" {
160 -re "\\$\[0-9\]+ = 4\\.5\r\n$gdb_prompt $" {
161 pass "print add3<float>(2.25,2.25)"
162 }
163 -re "No symbol \"add3<float>\" in current context.\r\n$gdb_prompt $" {
164 # TODO: kfail or xfail this
165 fail "print add3<float>(2.25,2.25)"
166 }
167 }
168
169 gdb_test_multiple "print add3<unsigned char>('A','A')" "print add3<unsigned char>('A','A')" {
170 -re "\\$\[0-9]+ = -126 .*$gdb_prompt $" {
171 pass "print add3<unsigned char>('A','A')"
172 }
173 -re "No symbol \"add3<unsigned char>\" in current context.\r\n$gdb_prompt $" {
174 # TODO: kfail or xfail this
175 fail "print add3<unsigned char>('A','A')"
176 }
177 }
178
179 gdb_test_multiple "print add4<int>(2,2)" "print add4<int>(2,2)" {
180 -re "\\$\[0-9\]+ = 4\r\n$gdb_prompt $" {
181 pass "print add4<int>(2,2)"
182 }
183 -re "No symbol \"add4<int>\" in current context.\r\n$gdb_prompt $" {
184 # TODO: kfail or xfail this
185 fail "print add4<int>(2,2)"
186 }
187 }
188
189 gdb_test_multiple "print add4<float>(2.25,2.25)" "print add4<float>(2.25,2.25)" {
190 -re "\\$\[0-9\]+ = 4\\.5\r\n$gdb_prompt $" {
191 pass "print add4<float>(2.25,2.25)"
192 }
193 -re "No symbol \"add4<float>\" in current context.\r\n$gdb_prompt $" {
194 # TODO: kfail or xfail this
195 fail "print add4<float>(2.25,2.25)"
196 }
197 }
198
199 gdb_test_multiple "print add4<unsigned char>('A','A')" "print add4<unsigned char>('A','A')" {
200 -re "\\$\[0-9]+ = -126 .*$gdb_prompt $" {
201 pass "print add4<unsigned char>('A','A')"
202 }
203 -re "No symbol \"add4<unsigned char>\" in current context.\r\n$gdb_prompt $" {
204 # TODO: kfail or xfail this
205 fail "print add4<unsigned char>('A','A')"
206 }
207 }
This page took 0.048183 seconds and 4 git commands to generate.