1 # Copyright 1998, 1999, 2001, 2003, 2004, 2007, 2008, 2009
2 # 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 # 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)
21 # source files cttiadd.cc, cttiadd1.cc, cttiadd2.cc, cttiadd3.cc
23 # Call to template instantiations.
29 if { [skip_cplus_tests] } { continue }
31 set testfile "cttiadd"
32 set srcfile "${testfile}.cc"
33 set srcfile1 "${testfile}1.cc"
34 set srcfile2 "${testfile}2.cc"
35 set srcfile3 "${testfile}3.cc"
36 set objfile "${testfile}.o"
37 set objfile1 "${testfile}1.o"
38 set objfile2 "${testfile}2.o"
39 set objfile3 "${testfile}3.o"
40 set binfile "${objdir}/${subdir}/${testfile}"
42 if { [gdb_compile "$srcdir/$subdir/$srcfile" "$objdir/$subdir/$objfile" object {debug c++}] != "" } {
47 if { [gdb_compile "$srcdir/$subdir/$srcfile1" "$objdir/$subdir/$objfile1" object {debug c++}] != "" } {
52 if { [gdb_compile "$srcdir/$subdir/$srcfile2" "$objdir/$subdir/$objfile2" object {debug c++}] != "" } {
57 if { [gdb_compile "$srcdir/$subdir/$srcfile3" "$objdir/$subdir/$objfile3" object {debug c++}] != "" } {
62 if { [gdb_compile "$objdir/$subdir/$objfile $objdir/$subdir/$objfile1 $objdir/$subdir/$objfile2 $objdir/$subdir/$objfile3" "${binfile}" executable {debug c++}] != "" } {
67 if [get_compiler_info ${binfile} "c++"] {
73 gdb_reinitialize_dir $srcdir/$subdir
76 if ![runto_main] then {
77 perror "couldn't run to breakpoint"
81 gdb_breakpoint [gdb_get_line_number "marker add1"]
82 gdb_continue_to_breakpoint "marker add1"
84 gdb_test "print c" "\\$\[0-9\]+ = 194 .*"
85 gdb_test "print f" "\\$\[0-9\]+ = 9"
86 gdb_test "print i" "\\$\[0-9\]+ = 4"
88 # TODO: this needs more work before actually deploying it.
91 if { [ test_compiler_info gcc-*] } then { continue }
93 gdb_test_multiple "print add<int>(2,2)" "print add<int>(2,2)" {
94 -re "\\$\[0-9\]+ = 4\r\n$gdb_prompt $" {
95 pass "print add<int>(2,2)"
97 -re "No symbol \"add<int>\" in current context.\r\n$gdb_prompt $" {
98 # TODO: kfail or xfail this
99 fail "print add<int>(2,2)"
103 # Note: 2.25 and 4.5 are exactly representable in IEEE-ish formats
104 gdb_test_multiple "print add<float>(2.25,2.25)" "print add<float>(2.25,2.25)" {
105 -re "\\$\[0-9\]+ = 4\\.5\r\n$gdb_prompt $" {
106 pass "print add<float>(2.25,2.25)"
108 -re "No symbol \"add<float>\" in current context.\r\n$gdb_prompt $" {
109 # TODO: kfail or xfail this
110 fail "print add<float>(2.25,2.25)"
114 gdb_test_multiple "print add<unsigned char>('A','A')" "print add<unsigned char>('A','A')" {
115 -re "\\$\[0-9\]+ = 130 .*\r\n$gdb_prompt $" {
116 pass "print add<unsigned char>('A','A')"
118 -re "No symbol \"add<unsigned char>\" in current context.\r\n$gdb_prompt $" {
119 # TODO: kfail or xfail this
120 fail "print add<unsigned char>('A','A')"
124 gdb_test_multiple "print add2<int>(2,2)" "print add2<int>(2,2)" {
125 -re "\\$\[0-9\]+ = 4\r\n$gdb_prompt $" {
126 pass "print add2<int>(2,2)"
128 -re "No symbol \"add2<int>\" in current context.\r\n$gdb_prompt $" {
129 # TODO: kfail or xfail this
130 fail "print add2<int>(2,2)"
134 gdb_test_multiple "print add2<float>(2.25,2.25)" "print add2<float>(2.25,2.25)" {
135 -re "\\$\[0-9\]+ = 4\\.5\r\n$gdb_prompt $" {
136 pass "print add2<float>(2.25,2.25)"
138 -re "No symbol \"add2<float>\" in current context.\r\n$gdb_prompt $" {
139 # TODO: kfail or xfail this
140 fail "print add2<float>(2.25,2.25)"
144 gdb_test_multiple "print add2<unsigned char>('A','A')" "print add2<unsigned char>('A','A')" {
145 -re "\\$\[0-9]+ = 130 .*$gdb_prompt $" {
146 pass "print add2<unsigned char>('A','A')"
148 -re "No symbol \"add2<unsigned char>\" in current context.\r\n$gdb_prompt $" {
149 # TODO: kfail or xfail this
150 fail "print add2<unsigned char>('A','A')"
154 gdb_test_multiple "print add3<int>(2,2)" "print add3<int>(2,2)" {
155 -re "\\$\[0-9\]+ = 4\r\n$gdb_prompt $" {
156 pass "print add3<int>(2,2)"
158 -re "No symbol \"add3<int>\" in current context.\r\n$gdb_prompt $" {
159 # TODO: kfail or xfail this
160 fail "print add3<int>(2,2)"
164 gdb_test_multiple "print add3<float>(2.25,2.25)" "print add3<float>(2.25,2.25)" {
165 -re "\\$\[0-9\]+ = 4\\.5\r\n$gdb_prompt $" {
166 pass "print add3<float>(2.25,2.25)"
168 -re "No symbol \"add3<float>\" in current context.\r\n$gdb_prompt $" {
169 # TODO: kfail or xfail this
170 fail "print add3<float>(2.25,2.25)"
174 gdb_test_multiple "print add3<unsigned char>('A','A')" "print add3<unsigned char>('A','A')" {
175 -re "\\$\[0-9]+ = 130 .*$gdb_prompt $" {
176 pass "print add3<unsigned char>('A','A')"
178 -re "No symbol \"add3<unsigned char>\" in current context.\r\n$gdb_prompt $" {
179 # TODO: kfail or xfail this
180 fail "print add3<unsigned char>('A','A')"
184 gdb_test_multiple "print add4<int>(2,2)" "print add4<int>(2,2)" {
185 -re "\\$\[0-9\]+ = 4\r\n$gdb_prompt $" {
186 pass "print add4<int>(2,2)"
188 -re "No symbol \"add4<int>\" in current context.\r\n$gdb_prompt $" {
189 # TODO: kfail or xfail this
190 fail "print add4<int>(2,2)"
194 gdb_test_multiple "print add4<float>(2.25,2.25)" "print add4<float>(2.25,2.25)" {
195 -re "\\$\[0-9\]+ = 4\\.5\r\n$gdb_prompt $" {
196 pass "print add4<float>(2.25,2.25)"
198 -re "No symbol \"add4<float>\" in current context.\r\n$gdb_prompt $" {
199 # TODO: kfail or xfail this
200 fail "print add4<float>(2.25,2.25)"
204 gdb_test_multiple "print add4<unsigned char>('A','A')" "print add4<unsigned char>('A','A')" {
205 -re "\\$\[0-9]+ = 130 .*$gdb_prompt $" {
206 pass "print add4<unsigned char>('A','A')"
208 -re "No symbol \"add4<unsigned char>\" in current context.\r\n$gdb_prompt $" {
209 # TODO: kfail or xfail this
210 fail "print add4<unsigned char>('A','A')"