aboutsummaryrefslogtreecommitdiff
path: root/gdb/testsuite/gdb.cp/ctti.exp
blob: e2f5a1f8b5a4a2748e337db05426ed19cdd527d0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
# Copyright 1998, 1999, 2001, 2003, 2004, 2007, 2008, 2009
# Free Software Foundation, Inc.

# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

# This file is part of the gdb testsuite
# file written by Elena Zannoni (ezannoni@cygnus.com)
# rewritten by Michael Chastain (mec.gnu@mindspring.com)
#
# source files cttiadd.cc, cttiadd1.cc, cttiadd2.cc, cttiadd3.cc

# Call to template instantiations.

if $tracelevel then {
    strace $tracelevel
}

if { [skip_cplus_tests] } { continue }

set testfile "cttiadd"
set srcfile  "${testfile}.cc"
set srcfile1 "${testfile}1.cc"
set srcfile2 "${testfile}2.cc"
set srcfile3 "${testfile}3.cc"
set objfile  "${testfile}.o"
set objfile1 "${testfile}1.o"
set objfile2 "${testfile}2.o"
set objfile3 "${testfile}3.o"
set binfile  "${objdir}/${subdir}/${testfile}"

if { [gdb_compile "$srcdir/$subdir/$srcfile" "$objdir/$subdir/$objfile" object {debug c++}] != "" } {
     untested ctti.exp
     return -1
}

if { [gdb_compile "$srcdir/$subdir/$srcfile1" "$objdir/$subdir/$objfile1" object {debug c++}] != "" } {
     untested ctti.exp
     return -1
}

if { [gdb_compile "$srcdir/$subdir/$srcfile2" "$objdir/$subdir/$objfile2" object {debug c++}] != "" } {
     untested ctti.exp
     return -1
}

if { [gdb_compile "$srcdir/$subdir/$srcfile3" "$objdir/$subdir/$objfile3" object {debug c++}] != "" } {
     untested ctti.exp
     return -1
}

if { [gdb_compile "$objdir/$subdir/$objfile $objdir/$subdir/$objfile1 $objdir/$subdir/$objfile2 $objdir/$subdir/$objfile3" "${binfile}" executable {debug c++}] != "" } {
     untested ctti.exp
     return -1
}

if [get_compiler_info ${binfile} "c++"] {
    return -1;
}

gdb_exit
gdb_start
gdb_reinitialize_dir $srcdir/$subdir
gdb_load ${binfile}

if ![runto_main] then {
    perror "couldn't run to breakpoint"
    continue
}

gdb_breakpoint [gdb_get_line_number "marker add1"]
gdb_continue_to_breakpoint "marker add1"

gdb_test "print c" "\\$\[0-9\]+ = 194 .*"
gdb_test "print f" "\\$\[0-9\]+ = 9"
gdb_test "print i" "\\$\[0-9\]+ = 4"

# TODO: this needs more work before actually deploying it.
# So bail out here.

if { [ test_compiler_info gcc-*] } then { continue }

gdb_test_multiple "print add<int>(2,2)" "print add<int>(2,2)" {
    -re "\\$\[0-9\]+ = 4\r\n$gdb_prompt $" {
	pass "print add<int>(2,2)"
    }
    -re "No symbol \"add<int>\" in current context.\r\n$gdb_prompt $" {
	# TODO: kfail or xfail this
	fail "print add<int>(2,2)"
    }
}

# Note: 2.25 and 4.5 are exactly representable in IEEE-ish formats
gdb_test_multiple "print add<float>(2.25,2.25)" "print add<float>(2.25,2.25)" {
    -re "\\$\[0-9\]+ = 4\\.5\r\n$gdb_prompt $" {
	pass "print add<float>(2.25,2.25)"
    }
    -re "No symbol \"add<float>\" in current context.\r\n$gdb_prompt $" {
	# TODO: kfail or xfail this
	fail "print add<float>(2.25,2.25)"
    }
}

gdb_test_multiple "print add<unsigned char>('A','A')" "print add<unsigned char>('A','A')" {
    -re "\\$\[0-9\]+ = -126 .*\r\n$gdb_prompt $" {
	pass "print add<unsigned char>('A','A')"
    }
    -re "No symbol \"add<unsigned char>\" in current context.\r\n$gdb_prompt $" {
	# TODO: kfail or xfail this
	fail "print add<unsigned char>('A','A')"
    }
}

gdb_test_multiple "print add2<int>(2,2)" "print add2<int>(2,2)" {
    -re "\\$\[0-9\]+ = 4\r\n$gdb_prompt $" {
	pass "print add2<int>(2,2)"
    }
    -re "No symbol \"add2<int>\" in current context.\r\n$gdb_prompt $" {
	# TODO: kfail or xfail this
	fail "print add2<int>(2,2)"
    }
}

gdb_test_multiple "print add2<float>(2.25,2.25)" "print add2<float>(2.25,2.25)" {
    -re "\\$\[0-9\]+ = 4\\.5\r\n$gdb_prompt $" {
	pass "print add2<float>(2.25,2.25)"
    }
    -re "No symbol \"add2<float>\" in current context.\r\n$gdb_prompt $" {
	# TODO: kfail or xfail this
	fail "print add2<float>(2.25,2.25)"
    }
}

gdb_test_multiple "print add2<unsigned char>('A','A')" "print add2<unsigned char>('A','A')" {
    -re "\\$\[0-9]+ = -126 .*$gdb_prompt $" {
	pass "print add2<unsigned char>('A','A')"
    }
    -re "No symbol \"add2<unsigned char>\" in current context.\r\n$gdb_prompt $" {
	# TODO: kfail or xfail this
	fail "print add2<unsigned char>('A','A')"
    }
}

gdb_test_multiple "print add3<int>(2,2)" "print add3<int>(2,2)" {
    -re "\\$\[0-9\]+ = 4\r\n$gdb_prompt $" {
	pass "print add3<int>(2,2)"
    }
    -re "No symbol \"add3<int>\" in current context.\r\n$gdb_prompt $" {
	# TODO: kfail or xfail this
	fail "print add3<int>(2,2)"
    }
}

gdb_test_multiple "print add3<float>(2.25,2.25)" "print add3<float>(2.25,2.25)" {
    -re "\\$\[0-9\]+ = 4\\.5\r\n$gdb_prompt $" {
	pass "print add3<float>(2.25,2.25)"
    }
    -re "No symbol \"add3<float>\" in current context.\r\n$gdb_prompt $" {
	# TODO: kfail or xfail this
	fail "print add3<float>(2.25,2.25)"
    }
}

gdb_test_multiple "print add3<unsigned char>('A','A')" "print add3<unsigned char>('A','A')" {
    -re "\\$\[0-9]+ = -126 .*$gdb_prompt $" {
	pass "print add3<unsigned char>('A','A')"
    }
    -re "No symbol \"add3<unsigned char>\" in current context.\r\n$gdb_prompt $" {
	# TODO: kfail or xfail this
	fail "print add3<unsigned char>('A','A')"
    }
}

gdb_test_multiple "print add4<int>(2,2)" "print add4<int>(2,2)" {
    -re "\\$\[0-9\]+ = 4\r\n$gdb_prompt $" {
	pass "print add4<int>(2,2)"
    }
    -re "No symbol \"add4<int>\" in current context.\r\n$gdb_prompt $" {
	# TODO: kfail or xfail this
	fail "print add4<int>(2,2)"
    }
}

gdb_test_multiple "print add4<float>(2.25,2.25)" "print add4<float>(2.25,2.25)" {
    -re "\\$\[0-9\]+ = 4\\.5\r\n$gdb_prompt $" {
	pass "print add4<float>(2.25,2.25)"
    }
    -re "No symbol \"add4<float>\" in current context.\r\n$gdb_prompt $" {
	# TODO: kfail or xfail this
	fail "print add4<float>(2.25,2.25)"
    }
}

gdb_test_multiple "print add4<unsigned char>('A','A')" "print add4<unsigned char>('A','A')" {
    -re "\\$\[0-9]+ = -126 .*$gdb_prompt $" {
	pass "print add4<unsigned char>('A','A')"
    }
    -re "No symbol \"add4<unsigned char>\" in current context.\r\n$gdb_prompt $" {
	# TODO: kfail or xfail this
	fail "print add4<unsigned char>('A','A')"
    }
}