]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - gdb/testsuite/gdb.c++/derivation.exp
Initial creation of sourceware repository
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.c++ / derivation.exp
1 # Copyright (C) 1998 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 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
42 set testfile "derivation"
43 set srcfile ${testfile}.cc
44 set binfile ${objdir}/${subdir}/${testfile}
45
46 if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug c++}] != "" } {
47 gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
48 }
49
50 gdb_exit
51 gdb_start
52 gdb_reinitialize_dir $srcdir/$subdir
53 gdb_load ${binfile}
54 remote_file build delete ${binfile}.ci
55 if {![istarget "hppa*-*-hpux*"]} {
56 if { [gdb_compile "${srcdir}/${subdir}/compiler.cc" "${binfile}.ci" preprocess ""] != ""
57 } {
58 gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will auto
59 matically fail."
60 }
61 } else {
62 if { [gdb_preprocess "${srcdir}/${subdir}/compiler.cc" "${binfile}.ci" "c++"] != "" } {
63 perror "Couldn't make ${binfile}.ci file"
64 return 1;
65 }
66 }
67
68 source ${binfile}.ci
69
70 #
71 # set it up at a breakpoint so we can play with the variable values
72 #
73 if ![runto_main] then {
74 perror "couldn't run to breakpoint"
75 continue
76 }
77
78 send_gdb "break marker1\n" ; gdb_expect -re ".*$gdb_prompt $"
79
80 send_gdb "cont\n"
81 gdb_expect {
82 -re "Break.* marker1 \\(\\) at .*:$decimal.*$gdb_prompt $" {
83 send_gdb "up\n"
84 gdb_expect {
85 -re ".*$gdb_prompt $" {}
86 timeout { fail "up from marker1" }
87 }
88 }
89 -re "$gdb_prompt $" { fail "continue to marker1" }
90 timeout { fail "(timeout) continue to marker1" }
91 }
92
93
94
95 send_gdb "print a_instance\n"
96 gdb_expect {
97 -re ".\[0-9\]* = \{a = 1, aa = 2\}\r\n$gdb_prompt $" {
98 pass "print value of a_instance"
99 }
100 -re ".*$gdb_prompt $" { fail "print value of a_instance" }
101 timeout { fail "(timeout) print value of a_instance" }
102 }
103
104
105 send_gdb "ptype a_instance\n"
106 gdb_expect {
107 -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" }
108 -re ".*$gdb_prompt $" { fail "ptype a_instance" }
109 timeout { fail "(timeout) ptype a_instance" }
110 }
111
112
113 send_gdb "print d_instance\n"
114 gdb_expect {
115 -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 $" {
116 pass "print value of d_instance"
117 }
118 -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 $" {
119 pass "print value of d_instance"
120 }
121 -re ".*$gdb_prompt $" { fail "print value of d_instance" }
122 timeout { fail "(timeout) print value of d_instance" }
123 }
124
125 if {$gcc_compiled} then {
126 send_gdb "ptype d_instance\n"
127 gdb_expect {
128 -re "type = class D : private A, public B, 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" }
129 -re ".*$gdb_prompt $" { fail "ptype d_instance" }
130 timeout { fail "(timeout) ptype d_instance" }
131 }
132 } else {
133 send_gdb "ptype d_instance\n"
134 gdb_expect {
135 -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" }
136 -re ".*$gdb_prompt $" { fail "ptype d_instance" }
137 timeout { fail "(timeout) ptype d_instance" }
138 }
139 }
140
141
142 send_gdb "print e_instance\n"
143 gdb_expect {
144 -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 $" {
145 pass "print value of e_instance"
146 }
147 -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 $" {
148 pass "print value of e_instance"
149 }
150 -re ".*$gdb_prompt $" { fail "print value of e_instance" }
151 timeout { fail "(timeout) print value of e_instance" }
152 }
153
154 if {$gcc_compiled} {
155 send_gdb "ptype e_instance\n"
156 gdb_expect {
157 -re "type = class E : public A, private B, 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" }
158 -re ".*$gdb_prompt $" { fail "ptype e_instance" }
159 timeout { fail "(timeout) ptype e_instance" }
160 }
161 } else {
162 send_gdb "ptype e_instance\n"
163 gdb_expect {
164 -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" }
165 -re ".*$gdb_prompt $" { fail "ptype e_instance" }
166 timeout { fail "(timeout) ptype e_instance" }
167 }
168 }
169
170
171 send_gdb "print f_instance\n"
172 gdb_expect {
173 -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 $" {
174 pass "print value of f_instance"
175 }
176 -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 $" {
177 pass "print value of f_instance"
178 }
179 -re ".*$gdb_prompt $" { fail "print value of f_instance" }
180 timeout { fail "(timeout) print value of f_instance" }
181 }
182
183 send_gdb "ptype f_instance\n"
184 gdb_expect {
185 -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" }
186 -re ".*$gdb_prompt $" { fail "ptype f_instance" }
187 timeout { fail "(timeout) ptype f_instance" }
188 }
189
190
191
192 send_gdb "print d_instance.a\n"
193 gdb_expect {
194 -re ".\[0-9\]* = 1.*$gdb_prompt $" {
195 pass "print value of d_instance.a"
196 }
197 -re ".*$gdb_prompt $" { fail "print value of d_instance.a" }
198 timeout { fail "(timeout) print value of d_instance.a" }
199 }
200
201 send_gdb "print d_instance.aa\n"
202 gdb_expect {
203 -re ".\[0-9\]* = 2.*$gdb_prompt $" {
204 pass "print value of d_instance.aa"
205 }
206 -re ".*$gdb_prompt $" { fail "print value of d_instance.aa" }
207 timeout { fail "(timeout) print value of d_instance.aa" }
208 }
209
210 send_gdb "print d_instance.b\n"
211 gdb_expect {
212 -re ".\[0-9\]* = 3.*$gdb_prompt $" {
213 pass "print value of d_instance.b"
214 }
215 -re ".*$gdb_prompt $" { fail "print value of d_instance.b" }
216 timeout { fail "(timeout) print value of d_instance.b" }
217 }
218
219 send_gdb "print d_instance.bb\n"
220 gdb_expect {
221 -re ".\[0-9\]* = 4.*$gdb_prompt $" {
222 pass "print value of d_instance.bb"
223 }
224 -re ".*$gdb_prompt $" { fail "print value of d_instance.bb" }
225 timeout { fail "(timeout) print value of d_instance.bb" }
226 }
227
228 send_gdb "print d_instance.c\n"
229 gdb_expect {
230 -re ".\[0-9\]* = 5.*$gdb_prompt $" {
231 pass "print value of d_instance.c"
232 }
233 -re ".*$gdb_prompt $" { fail "print value of d_instance.c" }
234 timeout { fail "(timeout) print value of d_instance.c" }
235 }
236
237 send_gdb "print d_instance.cc\n"
238 gdb_expect {
239 -re ".\[0-9\]* = 6.*$gdb_prompt $" {
240 pass "print value of d_instance.cc"
241 }
242 -re ".*$gdb_prompt $" { fail "print value of d_instance.cc" }
243 timeout { fail "(timeout) print value of d_instance.cc" }
244 }
245
246 send_gdb "print d_instance.d\n"
247 gdb_expect {
248 -re ".\[0-9\]* = 7.*$gdb_prompt $" {
249 pass "print value of d_instance.d"
250 }
251 -re ".*$gdb_prompt $" { fail "print value of d_instance.d" }
252 timeout { fail "(timeout) print value of d_instance.d" }
253 }
254
255 send_gdb "print d_instance.dd\n"
256 gdb_expect {
257 -re ".\[0-9\]* = 8.*$gdb_prompt $" {
258 pass "print value of d_instance.dd"
259 }
260 -re ".*$gdb_prompt $" { fail "print value of d_instance.dd" }
261 timeout { fail "(timeout) print value of d_instance.dd" }
262 }
263
264 send_gdb "print g_instance.a\n"
265 gdb_expect {
266 -re ".\[0-9\]* = 15.*$gdb_prompt $" {
267 pass "print value of g_instance.a"
268 }
269 -re ".*$gdb_prompt $" { fail "print value of g_instance.a" }
270 timeout { fail "(timeout) print value of g_instance.a" }
271 }
272
273 send_gdb "print g_instance.b\n"
274 gdb_expect {
275 -re ".\[0-9\]* = 16.*$gdb_prompt $" {
276 pass "print value of g_instance.b"
277 }
278 -re ".*$gdb_prompt $" { fail "print value of g_instance.b" }
279 timeout { fail "(timeout) print value of g_instance.b" }
280 }
281
282 send_gdb "print g_instance.c\n"
283 gdb_expect {
284 -re ".\[0-9\]* = 17.*$gdb_prompt $" {
285 pass "print value of g_instance.c"
286 }
287 -re ".*$gdb_prompt $" { fail "print value of g_instance.c" }
288 timeout { fail "(timeout) print value of g_instance.c" }
289 }
290
291 send_gdb "print g_instance.afoo()\n"
292 gdb_expect {
293 -re ".\[0-9\]* = 1.*$gdb_prompt $" {
294 pass "print value of g_instance.afoo()"
295 }
296 -re ".*$gdb_prompt $" { fail "print value of g_instance.afoo()" }
297 timeout { fail "(timeout) print value of g_instance.afoo()" }
298 }
299
300 send_gdb "print g_instance.bfoo()\n"
301 gdb_expect {
302 -re ".\[0-9\]* = 2.*$gdb_prompt $" {
303 pass "print value of g_instance.bfoo()"
304 }
305 -re ".*$gdb_prompt $" { fail "print value of g_instance.bfoo()" }
306 timeout { fail "(timeout) print value of g_instance.bfoo()" }
307 }
308
309 send_gdb "print g_instance.cfoo()\n"
310 gdb_expect {
311 -re ".\[0-9\]* = 3.*$gdb_prompt $" {
312 pass "print value of g_instance.cfoo()"
313 }
314 -re ".*$gdb_prompt $" { fail "print value of g_instance.cfoo()" }
315 timeout { fail "(timeout) print value of g_instance.cfoo()" }
316 }