1# Copyright 1998, 1999, 2001, 2003, 2004, 2007 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 3 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, see <http://www.gnu.org/licenses/>. 15 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) 19# 20# source files cttiadd.cc, cttiadd1.cc, cttiadd2.cc, cttiadd3.cc 21 22# Call to template instantiations. 23 24if $tracelevel then { 25 strace $tracelevel 26} 27 28if { [skip_cplus_tests] } { continue } 29 30set testfile "cttiadd" 31set srcfile "${testfile}.cc" 32set srcfile1 "${testfile}1.cc" 33set srcfile2 "${testfile}2.cc" 34set srcfile3 "${testfile}3.cc" 35set objfile "${testfile}.o" 36set objfile1 "${testfile}1.o" 37set objfile2 "${testfile}2.o" 38set objfile3 "${testfile}3.o" 39set binfile "${objdir}/${subdir}/${testfile}" 40 41if { [gdb_compile "$srcdir/$subdir/$srcfile" "$objdir/$subdir/$objfile" object {debug c++}] != "" } { 42 untested ctti.exp 43 return -1 44} 45 46if { [gdb_compile "$srcdir/$subdir/$srcfile1" "$objdir/$subdir/$objfile1" object {debug c++}] != "" } { 47 untested ctti.exp 48 return -1 49} 50 51if { [gdb_compile "$srcdir/$subdir/$srcfile2" "$objdir/$subdir/$objfile2" object {debug c++}] != "" } { 52 untested ctti.exp 53 return -1 54} 55 56if { [gdb_compile "$srcdir/$subdir/$srcfile3" "$objdir/$subdir/$objfile3" object {debug c++}] != "" } { 57 untested ctti.exp 58 return -1 59} 60 61if { [gdb_compile "$objdir/$subdir/$objfile $objdir/$subdir/$objfile1 $objdir/$subdir/$objfile2 $objdir/$subdir/$objfile3" "${binfile}" executable {debug c++}] != "" } { 62 untested ctti.exp 63 return -1 64} 65 66if [get_compiler_info ${binfile} "c++"] { 67 return -1; 68} 69 70gdb_exit 71gdb_start 72gdb_reinitialize_dir $srcdir/$subdir 73gdb_load ${binfile} 74 75if ![runto_main] then { 76 perror "couldn't run to breakpoint" 77 continue 78} 79 80gdb_breakpoint [gdb_get_line_number "marker add1"] 81gdb_continue_to_breakpoint "marker add1" 82 83gdb_test "print c" "\\$\[0-9\]+ = 194 .*" 84gdb_test "print f" "\\$\[0-9\]+ = 9" 85gdb_test "print i" "\\$\[0-9\]+ = 4" 86 87# TODO: this needs more work before actually deploying it. 88# So bail out here. 89 90if { [ test_compiler_info gcc-*] } then { continue } 91 92gdb_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)" 95 } 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)" 99 } 100} 101 102# Note: 2.25 and 4.5 are exactly representable in IEEE-ish formats 103gdb_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)" 106 } 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)" 110 } 111} 112 113gdb_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')" 116 } 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')" 120 } 121} 122 123gdb_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)" 126 } 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)" 130 } 131} 132 133gdb_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)" 136 } 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)" 140 } 141} 142 143gdb_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')" 146 } 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')" 150 } 151} 152 153gdb_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)" 156 } 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)" 160 } 161} 162 163gdb_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)" 166 } 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)" 170 } 171} 172 173gdb_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')" 176 } 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')" 180 } 181} 182 183gdb_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)" 186 } 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)" 190 } 191} 192 193gdb_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)" 196 } 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)" 200 } 201} 202 203gdb_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')" 206 } 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')" 210 } 211} 212