Commit | Line | Data |
---|---|---|
725f922e | 1 | # Copyright 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc. |
c906108c SS |
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 | # Please email any bugs, comments, and/or additions to this file to: | |
18 | # bug-gdb@prep.ai.mit.edu | |
19 | ||
20 | # This file was written by Elena Zannoni (ezannoni@cygnus.com) | |
21 | ||
22 | # This file is part of the gdb testsuite | |
23 | # | |
24 | ||
25 | # | |
26 | # tests for inheritance, with several derivations types combinations (private, | |
27 | # public, protected) | |
28 | # classes have simple members and member functions. | |
29 | # | |
30 | ||
31 | ||
32 | if $tracelevel then { | |
33 | strace $tracelevel | |
34 | } | |
35 | ||
36 | # | |
37 | # test running programs | |
38 | # | |
39 | set prms_id 0 | |
40 | set bug_id 0 | |
41 | ||
d4f3574e SS |
42 | if { [skip_cplus_tests] } { continue } |
43 | ||
c906108c SS |
44 | set testfile "derivation" |
45 | set srcfile ${testfile}.cc | |
46 | set binfile ${objdir}/${subdir}/${testfile} | |
47 | ||
d4f3574e SS |
48 | # Create and source the file that provides information about the compiler |
49 | # used to compile the test case. | |
50 | ||
51 | if [get_compiler_info ${binfile} "c++"] { | |
52 | return -1 | |
53 | } | |
54 | ||
c906108c SS |
55 | if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug c++}] != "" } { |
56 | gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." | |
57 | } | |
58 | ||
59 | gdb_exit | |
60 | gdb_start | |
61 | gdb_reinitialize_dir $srcdir/$subdir | |
62 | gdb_load ${binfile} | |
c906108c SS |
63 | |
64 | # | |
65 | # set it up at a breakpoint so we can play with the variable values | |
66 | # | |
67 | if ![runto_main] then { | |
68 | perror "couldn't run to breakpoint" | |
69 | continue | |
70 | } | |
71 | ||
f266096b MC |
72 | if ![runto 'marker1'] then { |
73 | perror "couldn't run to marker1" | |
74 | continue | |
75 | } | |
76 | ||
77 | gdb_test "up" ".*main.*" "up from marker1" | |
c906108c SS |
78 | |
79 | ||
80 | ||
81 | send_gdb "print a_instance\n" | |
82 | gdb_expect { | |
83 | -re ".\[0-9\]* = \{a = 1, aa = 2\}\r\n$gdb_prompt $" { | |
84 | pass "print value of a_instance" | |
85 | } | |
86 | -re ".*$gdb_prompt $" { fail "print value of a_instance" } | |
87 | timeout { fail "(timeout) print value of a_instance" } | |
88 | } | |
89 | ||
90 | ||
91 | send_gdb "ptype a_instance\n" | |
92 | gdb_expect { | |
1bc05c3a | 93 | -re "type = class A \{\r\n\[\t \]*public:\r\n\[\t \]*int a;\r\n\[\t \]*int aa;\[\r\n\t ]+A & operator=\\(A const ?&\\);\[\r\n\t ]+A\\((A const|const A) ?&\\);\[\r\n\t ]+A\\((void|)\\);\r\n\[\t \]*int afoo\\((void|)\\);\r\n\[\t \]*int foo\\((void|)\\);\r\n\}.*$gdb_prompt $" { pass "ptype a_instance (with synth ops)" } |
cbfa24cd | 94 | -re "type = class A \{\r\n\[\t \]*public:\r\n\[\t \]*int a;\r\n\[\t \]*int aa;\[\r\n\t \]+A\\(void\\);\r\n\[\t \]*int afoo\\((void|)\\);\r\n\[\t \]*int foo\\((void|)\\);\r\n\}.*$gdb_prompt $" { pass "ptype a_instance (no synth ops)" } |
c906108c SS |
95 | -re ".*$gdb_prompt $" { fail "ptype a_instance" } |
96 | timeout { fail "(timeout) ptype a_instance" } | |
97 | } | |
98 | ||
99 | ||
100 | send_gdb "print d_instance\n" | |
101 | gdb_expect { | |
102 | -re ".\[0-9\]* = \{<A> = \{a = 1, aa = 2\}, <B> = \{b = 3, bb = 4\}, <C> = \{c = 5, cc = 6\}, d = 7, dd = 8\}\r\n$gdb_prompt $" { | |
103 | pass "print value of d_instance" | |
104 | } | |
105 | -re ".\[0-9\]* = \{<class A> = \{a = 1, aa = 2\}, <class B> = \{b = 3, bb = 4\}, <class C> = \{c = 5, cc = 6\}, d = 7, dd = 8\}\r\n$gdb_prompt $" { | |
106 | pass "print value of d_instance" | |
107 | } | |
108 | -re ".*$gdb_prompt $" { fail "print value of d_instance" } | |
109 | timeout { fail "(timeout) print value of d_instance" } | |
110 | } | |
111 | ||
112 | if {$gcc_compiled} then { | |
113 | send_gdb "ptype d_instance\n" | |
114 | gdb_expect { | |
1bc05c3a | 115 | -re "type = class D : private A, public B, (protected|private) C \{\r\n\[\t \]*public:\r\n\[\t \]*int d;\r\n\[\t \]*int dd;\[\r\n\t ]+D & operator=\\(D const ?&\\);\[\r\n\t ]+D\\((D const|const D) ?&\\);\[\r\n\t \]+D\\((void|)\\);\r\n\[\t \]*int dfoo\\((void|)\\);\r\n\[\t \]*int foo\\((void|)\\);\r\n\}.*$gdb_prompt $" { pass "ptype d_instance" } |
3e36a0f4 DJ |
116 | -re "type = class D : private A, public B, (protected|private) C \{\r\n\[\t \]*public:\r\n\[\t \]*int d;\r\n\[\t \]*int dd;\[\r\n\t ]+D & operator=\\(D const ?&\\);\[\r\n\t ]+D\\((D const|const D) ?&\\);\[\r\n\t \]+D\\((void|)\\);\r\n\[\t \]*int dfoo\\((void|)\\);\r\n\[\t \]*int foo\\((void|)\\);\r\n\}.*$gdb_prompt $" { pass "ptype d_instance" } |
117 | -re "type = class D : private A, public B, (protected|private) C \{\r\n\[\t \]*public:\r\n\[\t \]*int d;\r\n\[\t \]*int dd;\[\r\n\t \]+D\\(void\\);\r\n\[\t \]*int dfoo\\((void|)\\);\r\n\[\t \]*int foo\\((void|)\\);\r\n\}.*$gdb_prompt $" { pass "ptype d_instance" } | |
c906108c SS |
118 | -re ".*$gdb_prompt $" { fail "ptype d_instance" } |
119 | timeout { fail "(timeout) ptype d_instance" } | |
120 | } | |
121 | } else { | |
122 | send_gdb "ptype d_instance\n" | |
123 | gdb_expect { | |
cbfa24cd | 124 | -re "type = class D : private A, public B, protected C \{\r\n\[\t \]*public:\r\n\[\t \]*int d;\r\n\[\t \]*int dd;\[\r\n\t \]+D\\(void\\);\r\n\[\t \]*int dfoo\\((void|)\\);\r\n\[\t \]*int foo\\((void|)\\);\r\n\}.*$gdb_prompt $" { pass "ptype d_instance" } |
c906108c SS |
125 | -re ".*$gdb_prompt $" { fail "ptype d_instance" } |
126 | timeout { fail "(timeout) ptype d_instance" } | |
127 | } | |
128 | } | |
129 | ||
130 | ||
131 | send_gdb "print e_instance\n" | |
132 | gdb_expect { | |
133 | -re ".\[0-9\]* = \{<A> = \{a = 1, aa = 2\}, <B> = \{b = 3, bb = 4\}, <C> = \{c = 5, cc = 6\}, e = 9, ee = 10\}\r\n$gdb_prompt $" { | |
134 | pass "print value of e_instance" | |
135 | } | |
136 | -re ".\[0-9\]* = \{<class A> = \{a = 1, aa = 2\}, <class B> = \{b = 3, bb = 4\}, <class C> = \{c = 5, cc = 6\}, e = 9, ee = 10\}\r\n$gdb_prompt $" { | |
137 | pass "print value of e_instance" | |
138 | } | |
139 | -re ".*$gdb_prompt $" { fail "print value of e_instance" } | |
140 | timeout { fail "(timeout) print value of e_instance" } | |
141 | } | |
142 | ||
143 | if {$gcc_compiled} { | |
144 | send_gdb "ptype e_instance\n" | |
145 | gdb_expect { | |
1bc05c3a | 146 | -re "type = class E : public A, private B, (protected|private) C \{\r\n\[\t \]*public:\r\n\[\t \]*int e;\r\n\[\t \]*int ee;\[\r\n\t ]+E & operator=\\(E const ?&\\);\[\r\n\t ]+E\\((E const|const E) ?&\\);\[\r\n\t \]+E\\((void|)\\);\r\n\[\t \]*int efoo\\((void|)\\);\r\n\[\t \]*int foo\\((void|)\\);\r\n\}.*$gdb_prompt $" { pass "ptype e_instance" } |
3e36a0f4 | 147 | -re "type = class E : public A, private B, (protected|private) C \{\r\n\[\t \]*public:\r\n\[\t \]*int e;\r\n\[\t \]*int ee;\[\r\n\t \]+E\\((void|)\\);\r\n\[\t \]*int efoo\\((void|)\\);\r\n\[\t \]*int foo\\((void|)\\);\r\n\}.*$gdb_prompt $" { pass "ptype e_instance" } |
c906108c SS |
148 | -re ".*$gdb_prompt $" { fail "ptype e_instance" } |
149 | timeout { fail "(timeout) ptype e_instance" } | |
150 | } | |
151 | } else { | |
152 | send_gdb "ptype e_instance\n" | |
153 | gdb_expect { | |
5178b9d6 | 154 | -re "type = class E : public A, private B, protected C \{\r\n\[\t \]*public:\r\n\[\t \]*int e;\r\n\[\t \]*int ee;\[\r\n\t \]+E\\((void|)\\);\r\n\[\t \]*int efoo\\((void|)\\);\r\n\[\t \]*int foo\\((void|)\\);\r\n\}.*$gdb_prompt $" { pass "ptype e_instance" } |
c906108c SS |
155 | -re ".*$gdb_prompt $" { fail "ptype e_instance" } |
156 | timeout { fail "(timeout) ptype e_instance" } | |
157 | } | |
158 | } | |
159 | ||
160 | ||
161 | send_gdb "print f_instance\n" | |
162 | gdb_expect { | |
163 | -re ".\[0-9\]* = \{<A> = \{a = 1, aa = 2\}, <B> = \{b = 3, bb = 4\}, <C> = \{c = 5, cc = 6\}, f = 11, ff = 12\}\r\n$gdb_prompt $" { | |
164 | pass "print value of f_instance" | |
165 | } | |
166 | -re ".\[0-9\]* = \{<class A> = \{a = 1, aa = 2\}, <class B> = \{b = 3, bb = 4\}, <class C> = \{c = 5, cc = 6\}, f = 11, ff = 12\}\r\n$gdb_prompt $" { | |
167 | pass "print value of f_instance" | |
168 | } | |
169 | -re ".*$gdb_prompt $" { fail "print value of f_instance" } | |
170 | timeout { fail "(timeout) print value of f_instance" } | |
171 | } | |
172 | ||
173 | send_gdb "ptype f_instance\n" | |
174 | gdb_expect { | |
1bc05c3a | 175 | -re "type = class F : private A, public B, private C \{\r\n\[\t \]*public:\r\n\[\t \]*int f;\r\n\[\t \]*int ff;\[\r\n\t ]+F & operator=\\(F const ?&\\);\[\r\n\t ]+F\\((F const|const F) ?&\\);\[\r\n\t \]+F\\((void|)\\);\r\n\[\t \]*int ffoo\\((void|)\\);\r\n\[\t \]*int foo\\((void|)\\);\r\n\}.*$gdb_prompt $" { pass "ptype f_instance" } |
5178b9d6 | 176 | -re "type = class F : private A, public B, private C \{\r\n\[\t \]*public:\r\n\[\t \]*int f;\r\n\[\t \]*int ff;\[\r\n\t \]+F\\((void|)\\);\r\n\[\t \]*int ffoo\\((void|)\\);\r\n\[\t \]*int foo\\((void|)\\);\r\n\}.*$gdb_prompt $" { pass "ptype f_instance" } |
c906108c SS |
177 | -re ".*$gdb_prompt $" { fail "ptype f_instance" } |
178 | timeout { fail "(timeout) ptype f_instance" } | |
179 | } | |
180 | ||
181 | ||
182 | ||
183 | send_gdb "print d_instance.a\n" | |
184 | gdb_expect { | |
185 | -re ".\[0-9\]* = 1.*$gdb_prompt $" { | |
186 | pass "print value of d_instance.a" | |
187 | } | |
188 | -re ".*$gdb_prompt $" { fail "print value of d_instance.a" } | |
189 | timeout { fail "(timeout) print value of d_instance.a" } | |
190 | } | |
191 | ||
192 | send_gdb "print d_instance.aa\n" | |
193 | gdb_expect { | |
194 | -re ".\[0-9\]* = 2.*$gdb_prompt $" { | |
195 | pass "print value of d_instance.aa" | |
196 | } | |
197 | -re ".*$gdb_prompt $" { fail "print value of d_instance.aa" } | |
198 | timeout { fail "(timeout) print value of d_instance.aa" } | |
199 | } | |
200 | ||
201 | send_gdb "print d_instance.b\n" | |
202 | gdb_expect { | |
203 | -re ".\[0-9\]* = 3.*$gdb_prompt $" { | |
204 | pass "print value of d_instance.b" | |
205 | } | |
206 | -re ".*$gdb_prompt $" { fail "print value of d_instance.b" } | |
207 | timeout { fail "(timeout) print value of d_instance.b" } | |
208 | } | |
209 | ||
210 | send_gdb "print d_instance.bb\n" | |
211 | gdb_expect { | |
212 | -re ".\[0-9\]* = 4.*$gdb_prompt $" { | |
213 | pass "print value of d_instance.bb" | |
214 | } | |
215 | -re ".*$gdb_prompt $" { fail "print value of d_instance.bb" } | |
216 | timeout { fail "(timeout) print value of d_instance.bb" } | |
217 | } | |
218 | ||
219 | send_gdb "print d_instance.c\n" | |
220 | gdb_expect { | |
221 | -re ".\[0-9\]* = 5.*$gdb_prompt $" { | |
222 | pass "print value of d_instance.c" | |
223 | } | |
224 | -re ".*$gdb_prompt $" { fail "print value of d_instance.c" } | |
225 | timeout { fail "(timeout) print value of d_instance.c" } | |
226 | } | |
227 | ||
228 | send_gdb "print d_instance.cc\n" | |
229 | gdb_expect { | |
230 | -re ".\[0-9\]* = 6.*$gdb_prompt $" { | |
231 | pass "print value of d_instance.cc" | |
232 | } | |
233 | -re ".*$gdb_prompt $" { fail "print value of d_instance.cc" } | |
234 | timeout { fail "(timeout) print value of d_instance.cc" } | |
235 | } | |
236 | ||
237 | send_gdb "print d_instance.d\n" | |
238 | gdb_expect { | |
239 | -re ".\[0-9\]* = 7.*$gdb_prompt $" { | |
240 | pass "print value of d_instance.d" | |
241 | } | |
242 | -re ".*$gdb_prompt $" { fail "print value of d_instance.d" } | |
243 | timeout { fail "(timeout) print value of d_instance.d" } | |
244 | } | |
245 | ||
246 | send_gdb "print d_instance.dd\n" | |
247 | gdb_expect { | |
248 | -re ".\[0-9\]* = 8.*$gdb_prompt $" { | |
249 | pass "print value of d_instance.dd" | |
250 | } | |
251 | -re ".*$gdb_prompt $" { fail "print value of d_instance.dd" } | |
252 | timeout { fail "(timeout) print value of d_instance.dd" } | |
253 | } | |
254 | ||
255 | send_gdb "print g_instance.a\n" | |
256 | gdb_expect { | |
adf40b2e JM |
257 | -re "warning.*$gdb_prompt $" { |
258 | # The compiler doesn't think this is ambiguous. | |
259 | fail "print value of g_instance.a" | |
260 | } | |
c906108c SS |
261 | -re ".\[0-9\]* = 15.*$gdb_prompt $" { |
262 | pass "print value of g_instance.a" | |
263 | } | |
264 | -re ".*$gdb_prompt $" { fail "print value of g_instance.a" } | |
265 | timeout { fail "(timeout) print value of g_instance.a" } | |
266 | } | |
267 | ||
268 | send_gdb "print g_instance.b\n" | |
269 | gdb_expect { | |
adf40b2e JM |
270 | -re "warning.*$gdb_prompt $" { |
271 | # The compiler doesn't think this is ambiguous. | |
272 | fail "print value of g_instance.b" | |
273 | } | |
c906108c SS |
274 | -re ".\[0-9\]* = 16.*$gdb_prompt $" { |
275 | pass "print value of g_instance.b" | |
276 | } | |
277 | -re ".*$gdb_prompt $" { fail "print value of g_instance.b" } | |
278 | timeout { fail "(timeout) print value of g_instance.b" } | |
279 | } | |
280 | ||
281 | send_gdb "print g_instance.c\n" | |
282 | gdb_expect { | |
adf40b2e JM |
283 | -re "warning.*$gdb_prompt $" { |
284 | # The compiler doesn't think this is ambiguous. | |
285 | fail "print value of g_instance.c" | |
286 | } | |
c906108c SS |
287 | -re ".\[0-9\]* = 17.*$gdb_prompt $" { |
288 | pass "print value of g_instance.c" | |
289 | } | |
290 | -re ".*$gdb_prompt $" { fail "print value of g_instance.c" } | |
291 | timeout { fail "(timeout) print value of g_instance.c" } | |
292 | } | |
293 | ||
294 | send_gdb "print g_instance.afoo()\n" | |
295 | gdb_expect { | |
296 | -re ".\[0-9\]* = 1.*$gdb_prompt $" { | |
297 | pass "print value of g_instance.afoo()" | |
298 | } | |
299 | -re ".*$gdb_prompt $" { fail "print value of g_instance.afoo()" } | |
300 | timeout { fail "(timeout) print value of g_instance.afoo()" } | |
301 | } | |
302 | ||
303 | send_gdb "print g_instance.bfoo()\n" | |
304 | gdb_expect { | |
305 | -re ".\[0-9\]* = 2.*$gdb_prompt $" { | |
306 | pass "print value of g_instance.bfoo()" | |
307 | } | |
308 | -re ".*$gdb_prompt $" { fail "print value of g_instance.bfoo()" } | |
309 | timeout { fail "(timeout) print value of g_instance.bfoo()" } | |
310 | } | |
311 | ||
312 | send_gdb "print g_instance.cfoo()\n" | |
313 | gdb_expect { | |
314 | -re ".\[0-9\]* = 3.*$gdb_prompt $" { | |
315 | pass "print value of g_instance.cfoo()" | |
316 | } | |
317 | -re ".*$gdb_prompt $" { fail "print value of g_instance.cfoo()" } | |
318 | timeout { fail "(timeout) print value of g_instance.cfoo()" } | |
319 | } |