1 # Copyright 1998, 1999, 2001, 2003, 2004, 2007 Free Software Foundation, Inc.
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 3 of the License, or
6 # (at your option) any later version.
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.
13 # You should have received a copy of the GNU General Public License
14 # along with this program. If not, see <http://www.gnu.org/licenses/>.
16 # This file is part of the gdb testsuite
17 # file written by Elena Zannoni (ezannoni@cygnus.com)
18 # rewritten by Michael Chastain (mec.gnu@mindspring.com)
20 # source files cttiadd.cc, cttiadd1.cc, cttiadd2.cc, cttiadd3.cc
22 # Call to template instantiations.
28 if { [skip_cplus_tests] } { continue }
30 set testfile "cttiadd"
31 set srcfile "${testfile}.cc"
32 set srcfile1 "${testfile}1.cc"
33 set srcfile2 "${testfile}2.cc"
34 set srcfile3 "${testfile}3.cc"
35 set objfile "${testfile}.o"
36 set objfile1 "${testfile}1.o"
37 set objfile2 "${testfile}2.o"
38 set objfile3 "${testfile}3.o"
39 set binfile "${objdir}/${subdir}/${testfile}"
41 if { [gdb_compile "$srcdir/$subdir/$srcfile" "$objdir/$subdir/$objfile" object {debug c++}] != "" } {
46 if { [gdb_compile "$srcdir/$subdir/$srcfile1" "$objdir/$subdir/$objfile1" object {debug c++}] != "" } {
51 if { [gdb_compile "$srcdir/$subdir/$srcfile2" "$objdir/$subdir/$objfile2" object {debug c++}] != "" } {
56 if { [gdb_compile "$srcdir/$subdir/$srcfile3" "$objdir/$subdir/$objfile3" object {debug c++}] != "" } {
61 if { [gdb_compile "$objdir/$subdir/$objfile $objdir/$subdir/$objfile1 $objdir/$subdir/$objfile2 $objdir/$subdir/$objfile3" "${binfile}" executable {debug c++}] != "" } {
66 if [get_compiler_info ${binfile} "c++"] {
72 gdb_reinitialize_dir $srcdir/$subdir
75 if ![runto_main] then {
76 perror "couldn't run to breakpoint"
80 gdb_breakpoint [gdb_get_line_number "marker add1"]
81 gdb_continue_to_breakpoint "marker add1"
83 gdb_test "print c" "\\$\[0-9\]+ = 194 .*"
84 gdb_test "print f" "\\$\[0-9\]+ = 9"
85 gdb_test "print i" "\\$\[0-9\]+ = 4"
87 # TODO: this needs more work before actually deploying it.
90 if { [ test_compiler_info gcc-*] } then { continue }
92 gdb_test_multiple "print add<int>(2,2)" "print add<int>(2,2)" {
93 -re "\\$\[0-9\]+ = 4\r\n$gdb_prompt $" {
94 pass "print add<int>(2,2)"
96 -re "No symbol \"add<int>\" in current context.\r\n$gdb_prompt $" {
97 # TODO: kfail or xfail this
98 fail "print add<int>(2,2)"
102 # Note: 2.25 and 4.5 are exactly representable in IEEE-ish formats
103 gdb_test_multiple "print add<float>(2.25,2.25)" "print add<float>(2.25,2.25)" {
104 -re "\\$\[0-9\]+ = 4\\.5\r\n$gdb_prompt $" {
105 pass "print add<float>(2.25,2.25)"
107 -re "No symbol \"add<float>\" in current context.\r\n$gdb_prompt $" {
108 # TODO: kfail or xfail this
109 fail "print add<float>(2.25,2.25)"
113 gdb_test_multiple "print add<unsigned char>('A','A')" "print add<unsigned char>('A','A')" {
114 -re "\\$\[0-9\]+ = -126 .*\r\n$gdb_prompt $" {
115 pass "print add<unsigned char>('A','A')"
117 -re "No symbol \"add<unsigned char>\" in current context.\r\n$gdb_prompt $" {
118 # TODO: kfail or xfail this
119 fail "print add<unsigned char>('A','A')"
123 gdb_test_multiple "print add2<int>(2,2)" "print add2<int>(2,2)" {
124 -re "\\$\[0-9\]+ = 4\r\n$gdb_prompt $" {
125 pass "print add2<int>(2,2)"
127 -re "No symbol \"add2<int>\" in current context.\r\n$gdb_prompt $" {
128 # TODO: kfail or xfail this
129 fail "print add2<int>(2,2)"
133 gdb_test_multiple "print add2<float>(2.25,2.25)" "print add2<float>(2.25,2.25)" {
134 -re "\\$\[0-9\]+ = 4\\.5\r\n$gdb_prompt $" {
135 pass "print add2<float>(2.25,2.25)"
137 -re "No symbol \"add2<float>\" in current context.\r\n$gdb_prompt $" {
138 # TODO: kfail or xfail this
139 fail "print add2<float>(2.25,2.25)"
143 gdb_test_multiple "print add2<unsigned char>('A','A')" "print add2<unsigned char>('A','A')" {
144 -re "\\$\[0-9]+ = -126 .*$gdb_prompt $" {
145 pass "print add2<unsigned char>('A','A')"
147 -re "No symbol \"add2<unsigned char>\" in current context.\r\n$gdb_prompt $" {
148 # TODO: kfail or xfail this
149 fail "print add2<unsigned char>('A','A')"
153 gdb_test_multiple "print add3<int>(2,2)" "print add3<int>(2,2)" {
154 -re "\\$\[0-9\]+ = 4\r\n$gdb_prompt $" {
155 pass "print add3<int>(2,2)"
157 -re "No symbol \"add3<int>\" in current context.\r\n$gdb_prompt $" {
158 # TODO: kfail or xfail this
159 fail "print add3<int>(2,2)"
163 gdb_test_multiple "print add3<float>(2.25,2.25)" "print add3<float>(2.25,2.25)" {
164 -re "\\$\[0-9\]+ = 4\\.5\r\n$gdb_prompt $" {
165 pass "print add3<float>(2.25,2.25)"
167 -re "No symbol \"add3<float>\" in current context.\r\n$gdb_prompt $" {
168 # TODO: kfail or xfail this
169 fail "print add3<float>(2.25,2.25)"
173 gdb_test_multiple "print add3<unsigned char>('A','A')" "print add3<unsigned char>('A','A')" {
174 -re "\\$\[0-9]+ = -126 .*$gdb_prompt $" {
175 pass "print add3<unsigned char>('A','A')"
177 -re "No symbol \"add3<unsigned char>\" in current context.\r\n$gdb_prompt $" {
178 # TODO: kfail or xfail this
179 fail "print add3<unsigned char>('A','A')"
183 gdb_test_multiple "print add4<int>(2,2)" "print add4<int>(2,2)" {
184 -re "\\$\[0-9\]+ = 4\r\n$gdb_prompt $" {
185 pass "print add4<int>(2,2)"
187 -re "No symbol \"add4<int>\" in current context.\r\n$gdb_prompt $" {
188 # TODO: kfail or xfail this
189 fail "print add4<int>(2,2)"
193 gdb_test_multiple "print add4<float>(2.25,2.25)" "print add4<float>(2.25,2.25)" {
194 -re "\\$\[0-9\]+ = 4\\.5\r\n$gdb_prompt $" {
195 pass "print add4<float>(2.25,2.25)"
197 -re "No symbol \"add4<float>\" in current context.\r\n$gdb_prompt $" {
198 # TODO: kfail or xfail this
199 fail "print add4<float>(2.25,2.25)"
203 gdb_test_multiple "print add4<unsigned char>('A','A')" "print add4<unsigned char>('A','A')" {
204 -re "\\$\[0-9]+ = -126 .*$gdb_prompt $" {
205 pass "print add4<unsigned char>('A','A')"
207 -re "No symbol \"add4<unsigned char>\" in current context.\r\n$gdb_prompt $" {
208 # TODO: kfail or xfail this
209 fail "print add4<unsigned char>('A','A')"