OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [insight/] [gdb/] [testsuite/] [gdb.c++/] [derivation.exp] - Blame information for rev 1774

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 578 markom
# Copyright 1998, 1999, 2000, 2001 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
if { [skip_cplus_tests] } { continue }
43
 
44
set testfile "derivation"
45
set srcfile ${testfile}.cc
46
set binfile ${objdir}/${subdir}/${testfile}
47
 
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
 
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}
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
 
72
if ![runto 'marker1'] then {
73
    perror "couldn't run to marker1"
74
    continue
75
}
76
 
77
gdb_test "up" ".*main.*" "up from marker1"
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 {
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 &\\);\[\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)" }
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)" }
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 = 1, aa = 2\},  = \{b = 3, bb = 4\},  = \{c = 5, cc = 6\}, d = 7, dd = 8\}\r\n$gdb_prompt $" {
103
        pass "print value of d_instance"
104
      }
105
    -re ".\[0-9\]* = \{ = \{a = 1, aa = 2\},  = \{b = 3, bb = 4\},  = \{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 {
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 &\\);\[\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" }
116
          -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" }
117
          -re ".*$gdb_prompt $"   {  fail "ptype d_instance" }
118
          timeout             { fail "(timeout) ptype d_instance" }
119
      }
120
  } else {
121
      send_gdb "ptype d_instance\n"
122
      gdb_expect {
123
          -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" }
124
          -re ".*$gdb_prompt $"   {  fail "ptype d_instance" }
125
          timeout             { fail "(timeout) ptype d_instance" }
126
      }
127
  }
128
 
129
 
130
send_gdb "print e_instance\n"
131
gdb_expect {
132
    -re ".\[0-9\]* = \{ = \{a = 1, aa = 2\},  = \{b = 3, bb = 4\},  = \{c = 5, cc = 6\}, e = 9, ee = 10\}\r\n$gdb_prompt $" {
133
        pass "print value of e_instance"
134
      }
135
    -re ".\[0-9\]* = \{ = \{a = 1, aa = 2\},  = \{b = 3, bb = 4\},  = \{c = 5, cc = 6\}, e = 9, ee = 10\}\r\n$gdb_prompt $" {
136
        pass "print value of e_instance"
137
      }
138
    -re ".*$gdb_prompt $" { fail "print value of e_instance" }
139
    timeout           { fail "(timeout) print value of e_instance" }
140
  }
141
 
142
  if {$gcc_compiled} {
143
      send_gdb "ptype e_instance\n"
144
      gdb_expect {
145
          -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 &\\);\[\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" }
146
          -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" }
147
          -re ".*$gdb_prompt $"   {  fail "ptype e_instance" }
148
          timeout             { fail "(timeout) ptype e_instance" }
149
      }
150
  } else {
151
      send_gdb "ptype e_instance\n"
152
      gdb_expect {
153
          -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" }
154
          -re ".*$gdb_prompt $"   {  fail "ptype e_instance" }
155
          timeout             { fail "(timeout) ptype e_instance" }
156
      }
157
  }
158
 
159
 
160
send_gdb "print f_instance\n"
161
gdb_expect {
162
    -re ".\[0-9\]* = \{ = \{a = 1, aa = 2\},  = \{b = 3, bb = 4\},  = \{c = 5, cc = 6\}, f = 11, ff = 12\}\r\n$gdb_prompt $" {
163
        pass "print value of f_instance"
164
      }
165
    -re ".\[0-9\]* = \{ = \{a = 1, aa = 2\},  = \{b = 3, bb = 4\},  = \{c = 5, cc = 6\}, f = 11, ff = 12\}\r\n$gdb_prompt $" {
166
        pass "print value of f_instance"
167
      }
168
    -re ".*$gdb_prompt $" { fail "print value of f_instance" }
169
    timeout           { fail "(timeout) print value of f_instance" }
170
  }
171
 
172
send_gdb "ptype f_instance\n"
173
gdb_expect {
174
    -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" }
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\\(void\\);\r\n\[\t \]*int ffoo\\(void\\);\r\n\[\t \]*int foo\\(void\\);\r\n\}.*$gdb_prompt $"  { pass "ptype f_instance" }
176
    -re ".*$gdb_prompt $"   {  fail "ptype f_instance" }
177
    timeout             { fail "(timeout) ptype f_instance" }
178
}
179
 
180
 
181
 
182
send_gdb "print d_instance.a\n"
183
gdb_expect {
184
    -re ".\[0-9\]* = 1.*$gdb_prompt $" {
185
        pass "print value of d_instance.a"
186
      }
187
    -re ".*$gdb_prompt $" { fail "print value of d_instance.a" }
188
    timeout           { fail "(timeout) print value of d_instance.a" }
189
  }
190
 
191
send_gdb "print d_instance.aa\n"
192
gdb_expect {
193
    -re ".\[0-9\]* = 2.*$gdb_prompt $" {
194
        pass "print value of d_instance.aa"
195
      }
196
    -re ".*$gdb_prompt $" { fail "print value of d_instance.aa" }
197
    timeout           { fail "(timeout) print value of d_instance.aa" }
198
  }
199
 
200
send_gdb "print d_instance.b\n"
201
gdb_expect {
202
    -re ".\[0-9\]* = 3.*$gdb_prompt $" {
203
        pass "print value of d_instance.b"
204
      }
205
    -re ".*$gdb_prompt $" { fail "print value of d_instance.b" }
206
    timeout           { fail "(timeout) print value of d_instance.b" }
207
  }
208
 
209
send_gdb "print d_instance.bb\n"
210
gdb_expect {
211
    -re ".\[0-9\]* = 4.*$gdb_prompt $" {
212
        pass "print value of d_instance.bb"
213
      }
214
    -re ".*$gdb_prompt $" { fail "print value of d_instance.bb" }
215
    timeout           { fail "(timeout) print value of d_instance.bb" }
216
  }
217
 
218
send_gdb "print d_instance.c\n"
219
gdb_expect {
220
    -re ".\[0-9\]* = 5.*$gdb_prompt $" {
221
        pass "print value of d_instance.c"
222
      }
223
    -re ".*$gdb_prompt $" { fail "print value of d_instance.c" }
224
    timeout           { fail "(timeout) print value of d_instance.c" }
225
  }
226
 
227
send_gdb "print d_instance.cc\n"
228
gdb_expect {
229
    -re ".\[0-9\]* = 6.*$gdb_prompt $" {
230
        pass "print value of d_instance.cc"
231
      }
232
    -re ".*$gdb_prompt $" { fail "print value of d_instance.cc" }
233
    timeout           { fail "(timeout) print value of d_instance.cc" }
234
  }
235
 
236
send_gdb "print d_instance.d\n"
237
gdb_expect {
238
    -re ".\[0-9\]* = 7.*$gdb_prompt $" {
239
        pass "print value of d_instance.d"
240
      }
241
    -re ".*$gdb_prompt $" { fail "print value of d_instance.d" }
242
    timeout           { fail "(timeout) print value of d_instance.d" }
243
  }
244
 
245
send_gdb "print d_instance.dd\n"
246
gdb_expect {
247
    -re ".\[0-9\]* = 8.*$gdb_prompt $" {
248
        pass "print value of d_instance.dd"
249
      }
250
    -re ".*$gdb_prompt $" { fail "print value of d_instance.dd" }
251
    timeout           { fail "(timeout) print value of d_instance.dd" }
252
  }
253
 
254
send_gdb "print g_instance.a\n"
255
gdb_expect {
256
    -re "warning.*$gdb_prompt $" {
257
        # The compiler doesn't think this is ambiguous.
258
        fail "print value of g_instance.a"
259
    }
260
    -re ".\[0-9\]* = 15.*$gdb_prompt $" {
261
        pass "print value of g_instance.a"
262
      }
263
    -re ".*$gdb_prompt $" { fail "print value of g_instance.a" }
264
    timeout           { fail "(timeout) print value of g_instance.a" }
265
  }
266
 
267
send_gdb "print g_instance.b\n"
268
gdb_expect {
269
    -re "warning.*$gdb_prompt $" {
270
        # The compiler doesn't think this is ambiguous.
271
        fail "print value of g_instance.b"
272
    }
273
    -re ".\[0-9\]* = 16.*$gdb_prompt $" {
274
        pass "print value of g_instance.b"
275
      }
276
    -re ".*$gdb_prompt $" { fail "print value of g_instance.b" }
277
    timeout           { fail "(timeout) print value of g_instance.b" }
278
  }
279
 
280
send_gdb "print g_instance.c\n"
281
gdb_expect {
282
    -re "warning.*$gdb_prompt $" {
283
        # The compiler doesn't think this is ambiguous.
284
        fail "print value of g_instance.c"
285
    }
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
 
293
# The following cases always fail with g++ output, and should be fixed
294
# someday. -sts 1999-08-25
295
 
296
if { $gcc_compiled } { setup_xfail "*-*-*" }
297
send_gdb "print g_instance.afoo()\n"
298
gdb_expect {
299
    -re ".\[0-9\]* = 1.*$gdb_prompt $" {
300
        pass "print value of g_instance.afoo()"
301
      }
302
    -re ".*$gdb_prompt $" { fail "print value of g_instance.afoo()" }
303
    timeout           { fail "(timeout) print value of g_instance.afoo()" }
304
  }
305
 
306
if { $gcc_compiled } { setup_xfail "*-*-*" }
307
send_gdb "print g_instance.bfoo()\n"
308
gdb_expect {
309
    -re ".\[0-9\]* = 2.*$gdb_prompt $" {
310
        pass "print value of g_instance.bfoo()"
311
      }
312
    -re ".*$gdb_prompt $" { fail "print value of g_instance.bfoo()" }
313
    timeout           { fail "(timeout) print value of g_instance.bfoo()" }
314
  }
315
 
316
if { $gcc_compiled } { setup_xfail "*-*-*" }
317
send_gdb "print g_instance.cfoo()\n"
318
gdb_expect {
319
    -re ".\[0-9\]* = 3.*$gdb_prompt $" {
320
        pass "print value of g_instance.cfoo()"
321
      }
322
    -re ".*$gdb_prompt $" { fail "print value of g_instance.cfoo()" }
323
    timeout           { fail "(timeout) print value of g_instance.cfoo()" }
324
  }

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.