]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - gdb/testsuite/gdb.c++/derivation.exp
import gdb-19990422 snapshot
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.c++ / derivation.exp
CommitLineData
c906108c
SS
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
32if $tracelevel then {
33 strace $tracelevel
34 }
35
36#
37# test running programs
38#
39set prms_id 0
40set bug_id 0
41
42set testfile "derivation"
43set srcfile ${testfile}.cc
44set binfile ${objdir}/${subdir}/${testfile}
45
46if { [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
50gdb_exit
51gdb_start
52gdb_reinitialize_dir $srcdir/$subdir
53gdb_load ${binfile}
54remote_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
59matically 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
68source ${binfile}.ci
69
70#
71# set it up at a breakpoint so we can play with the variable values
72#
73if ![runto_main] then {
74 perror "couldn't run to breakpoint"
75 continue
76}
77
78send_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
95send_gdb "print a_instance\n"
96gdb_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
105send_gdb "ptype a_instance\n"
106gdb_expect {
7a292a7a
SS
107 -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 &\\);\[\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)" }
108 -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
109 -re ".*$gdb_prompt $" { fail "ptype a_instance" }
110 timeout { fail "(timeout) ptype a_instance" }
111}
112
113
114send_gdb "print d_instance\n"
115gdb_expect {
116 -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 $" {
117 pass "print value of d_instance"
118 }
119 -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 $" {
120 pass "print value of d_instance"
121 }
122 -re ".*$gdb_prompt $" { fail "print value of d_instance" }
123 timeout { fail "(timeout) print value of d_instance" }
124 }
125
126 if {$gcc_compiled} then {
127 send_gdb "ptype d_instance\n"
128 gdb_expect {
7a292a7a 129 -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 & operator=\\(D const &\\);\[\r\n\t ]+D\\(D const &\\);\[\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
130 -re ".*$gdb_prompt $" { fail "ptype d_instance" }
131 timeout { fail "(timeout) ptype d_instance" }
132 }
133 } else {
134 send_gdb "ptype d_instance\n"
135 gdb_expect {
136 -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" }
137 -re ".*$gdb_prompt $" { fail "ptype d_instance" }
138 timeout { fail "(timeout) ptype d_instance" }
139 }
140 }
141
142
143send_gdb "print e_instance\n"
144gdb_expect {
145 -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 $" {
146 pass "print value of e_instance"
147 }
148 -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 $" {
149 pass "print value of e_instance"
150 }
151 -re ".*$gdb_prompt $" { fail "print value of e_instance" }
152 timeout { fail "(timeout) print value of e_instance" }
153 }
154
155 if {$gcc_compiled} {
156 send_gdb "ptype e_instance\n"
157 gdb_expect {
7a292a7a 158 -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 & operator=\\(E const &\\);\[\r\n\t ]+E\\(E const &\\);\[\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
159 -re ".*$gdb_prompt $" { fail "ptype e_instance" }
160 timeout { fail "(timeout) ptype e_instance" }
161 }
162 } else {
163 send_gdb "ptype e_instance\n"
164 gdb_expect {
165 -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" }
166 -re ".*$gdb_prompt $" { fail "ptype e_instance" }
167 timeout { fail "(timeout) ptype e_instance" }
168 }
169 }
170
171
172send_gdb "print f_instance\n"
173gdb_expect {
174 -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 $" {
175 pass "print value of f_instance"
176 }
177 -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 $" {
178 pass "print value of f_instance"
179 }
180 -re ".*$gdb_prompt $" { fail "print value of f_instance" }
181 timeout { fail "(timeout) print value of f_instance" }
182 }
183
184send_gdb "ptype f_instance\n"
185gdb_expect {
7a292a7a 186 -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 &\\);\[\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
187 -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" }
188 -re ".*$gdb_prompt $" { fail "ptype f_instance" }
189 timeout { fail "(timeout) ptype f_instance" }
190}
191
192
193
194send_gdb "print d_instance.a\n"
195gdb_expect {
196 -re ".\[0-9\]* = 1.*$gdb_prompt $" {
197 pass "print value of d_instance.a"
198 }
199 -re ".*$gdb_prompt $" { fail "print value of d_instance.a" }
200 timeout { fail "(timeout) print value of d_instance.a" }
201 }
202
203send_gdb "print d_instance.aa\n"
204gdb_expect {
205 -re ".\[0-9\]* = 2.*$gdb_prompt $" {
206 pass "print value of d_instance.aa"
207 }
208 -re ".*$gdb_prompt $" { fail "print value of d_instance.aa" }
209 timeout { fail "(timeout) print value of d_instance.aa" }
210 }
211
212send_gdb "print d_instance.b\n"
213gdb_expect {
214 -re ".\[0-9\]* = 3.*$gdb_prompt $" {
215 pass "print value of d_instance.b"
216 }
217 -re ".*$gdb_prompt $" { fail "print value of d_instance.b" }
218 timeout { fail "(timeout) print value of d_instance.b" }
219 }
220
221send_gdb "print d_instance.bb\n"
222gdb_expect {
223 -re ".\[0-9\]* = 4.*$gdb_prompt $" {
224 pass "print value of d_instance.bb"
225 }
226 -re ".*$gdb_prompt $" { fail "print value of d_instance.bb" }
227 timeout { fail "(timeout) print value of d_instance.bb" }
228 }
229
230send_gdb "print d_instance.c\n"
231gdb_expect {
232 -re ".\[0-9\]* = 5.*$gdb_prompt $" {
233 pass "print value of d_instance.c"
234 }
235 -re ".*$gdb_prompt $" { fail "print value of d_instance.c" }
236 timeout { fail "(timeout) print value of d_instance.c" }
237 }
238
239send_gdb "print d_instance.cc\n"
240gdb_expect {
241 -re ".\[0-9\]* = 6.*$gdb_prompt $" {
242 pass "print value of d_instance.cc"
243 }
244 -re ".*$gdb_prompt $" { fail "print value of d_instance.cc" }
245 timeout { fail "(timeout) print value of d_instance.cc" }
246 }
247
248send_gdb "print d_instance.d\n"
249gdb_expect {
250 -re ".\[0-9\]* = 7.*$gdb_prompt $" {
251 pass "print value of d_instance.d"
252 }
253 -re ".*$gdb_prompt $" { fail "print value of d_instance.d" }
254 timeout { fail "(timeout) print value of d_instance.d" }
255 }
256
257send_gdb "print d_instance.dd\n"
258gdb_expect {
259 -re ".\[0-9\]* = 8.*$gdb_prompt $" {
260 pass "print value of d_instance.dd"
261 }
262 -re ".*$gdb_prompt $" { fail "print value of d_instance.dd" }
263 timeout { fail "(timeout) print value of d_instance.dd" }
264 }
265
266send_gdb "print g_instance.a\n"
267gdb_expect {
268 -re ".\[0-9\]* = 15.*$gdb_prompt $" {
269 pass "print value of g_instance.a"
270 }
271 -re ".*$gdb_prompt $" { fail "print value of g_instance.a" }
272 timeout { fail "(timeout) print value of g_instance.a" }
273 }
274
275send_gdb "print g_instance.b\n"
276gdb_expect {
277 -re ".\[0-9\]* = 16.*$gdb_prompt $" {
278 pass "print value of g_instance.b"
279 }
280 -re ".*$gdb_prompt $" { fail "print value of g_instance.b" }
281 timeout { fail "(timeout) print value of g_instance.b" }
282 }
283
284send_gdb "print g_instance.c\n"
285gdb_expect {
286 -re ".\[0-9\]* = 17.*$gdb_prompt $" {
287 pass "print value of g_instance.c"
288 }
289 -re ".*$gdb_prompt $" { fail "print value of g_instance.c" }
290 timeout { fail "(timeout) print value of g_instance.c" }
291 }
292
293send_gdb "print g_instance.afoo()\n"
294gdb_expect {
295 -re ".\[0-9\]* = 1.*$gdb_prompt $" {
296 pass "print value of g_instance.afoo()"
297 }
298 -re ".*$gdb_prompt $" { fail "print value of g_instance.afoo()" }
299 timeout { fail "(timeout) print value of g_instance.afoo()" }
300 }
301
302send_gdb "print g_instance.bfoo()\n"
303gdb_expect {
304 -re ".\[0-9\]* = 2.*$gdb_prompt $" {
305 pass "print value of g_instance.bfoo()"
306 }
307 -re ".*$gdb_prompt $" { fail "print value of g_instance.bfoo()" }
308 timeout { fail "(timeout) print value of g_instance.bfoo()" }
309 }
310
311send_gdb "print g_instance.cfoo()\n"
312gdb_expect {
313 -re ".\[0-9\]* = 3.*$gdb_prompt $" {
314 pass "print value of g_instance.cfoo()"
315 }
316 -re ".*$gdb_prompt $" { fail "print value of g_instance.cfoo()" }
317 timeout { fail "(timeout) print value of g_instance.cfoo()" }
318 }