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

Subversion Repositories or1k

[/] [or1k/] [trunk/] [gdb-5.3/] [gdb/] [testsuite/] [gdb.c++/] [classes.exp] - Blame information for rev 1765

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 1181 sfurman
# Copyright 1992, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002
2
# Free Software Foundation, Inc.
3
 
4
# This program is free software; you can redistribute it and/or modify
5
# it under the terms of the GNU General Public License as published by
6
# the Free Software Foundation; either version 2 of the License, or
7
# (at your option) any later version.
8
#
9
# This program is distributed in the hope that it will be useful,
10
# but WITHOUT ANY WARRANTY; without even the implied warranty of
11
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
# GNU General Public License for more details.
13
#
14
# You should have received a copy of the GNU General Public License
15
# along with this program; if not, write to the Free Software
16
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17
 
18
# Please email any bugs, comments, and/or additions to this file to:
19
# bug-gdb@prep.ai.mit.edu
20
 
21
# This file was written by Fred Fish. (fnf@cygnus.com)
22
 
23
set ws "\[\r\n\t \]+"
24
set nl "\[\r\n\]+"
25
 
26
if $tracelevel then {
27
        strace $tracelevel
28
}
29
 
30
if { [skip_cplus_tests] } { continue }
31
 
32
set testfile "misc"
33
set srcfile ${testfile}.cc
34
set binfile ${objdir}/${subdir}/${testfile}
35
 
36
# Create and source the file that provides information about the compiler
37
# used to compile the test case.
38
 
39
if [get_compiler_info ${binfile} "c++"] {
40
    return -1
41
}
42
 
43
if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug c++}] != "" } {
44
     gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
45
}
46
 
47
#
48
# Test ptype of class objects.
49
#
50
 
51
proc test_ptype_class_objects {} {
52
    global gdb_prompt
53
    global ws
54
    global nl
55
 
56
    # Note that struct members are public by default, so we don't print
57
    # "public:" for the public members of structs.
58
    # Accept it as an expected failure if gdb just fails to distinguish between
59
    # class and struct, and everything else is OK.
60
 
61
    send_gdb "ptype struct default_public_struct\n"
62
    gdb_expect {
63
        -re "type = struct default_public_struct \{${ws}int a;${ws}int b;$nl\}$nl$gdb_prompt $" {
64
            pass "ptype struct default_public_struct"
65
        }
66
        -re "type = class default_public_struct \{$nl.*int a;${ws}int b;$nl.*\}$nl$gdb_prompt $" {
67
            setup_xfail "*-*-*"
68
            fail "ptype struct default_public_struct"
69
        }
70
        -re ".*$gdb_prompt $" { fail "ptype struct default_public_struct" }
71
        timeout { fail "ptype struct default_public_struct (timeout)" ; return }
72
    }
73
 
74
    # Note that struct members are public by default, so we don't print
75
    # "public:" for the public members of structs.
76
    # Accept it as an expected failure if gdb just fails to distinguish between
77
    # class and struct, and everything else is OK.
78
 
79
    send_gdb "ptype struct explicit_public_struct\n"
80
    gdb_expect {
81
        -re "type = struct explicit_public_struct \{${ws}int a;${ws}int b;$nl.*\}$nl$gdb_prompt $" {
82
            pass "ptype struct explicit_public_struct"
83
        }
84
        -re "type = class explicit_public_struct \{$nl.*int a;${ws}int b;$nl.*\}$nl$gdb_prompt $" {
85
            setup_xfail "*-*-*"
86
            fail "ptype struct explicit_public_struct"
87
        }
88
        -re ".*$gdb_prompt $" { fail "ptype struct explicit_public_struct" }
89
        timeout { fail "ptype struct explicit_public_struct (timeout)" ; return }
90
    }
91
 
92
    # Accept it as an expected failure if gdb just fails to distinguish between
93
    # class and struct, and everything else is OK.
94
 
95
    setup_xfail_format "DWARF 1"
96
    send_gdb "ptype struct protected_struct\n"
97
    gdb_expect {
98
        -re "type = struct protected_struct \{${ws}protected:${ws}int a;${ws}int b;$nl\}$nl$gdb_prompt $" {
99
            pass "ptype struct protected_struct (FIXME)"
100
        }
101
        -re "type = class protected_struct \{${ws}protected:${ws}int a;${ws}int b;$nl.*\}$nl$gdb_prompt $" {
102
            setup_xfail "*-*-*"
103
            fail "ptype struct protected_struct (FIXME)"
104
        }
105
        -re ".*$gdb_prompt $" { fail "ptype struct protected_struct" }
106
        timeout { fail "ptype struct protected_struct (timeout)" ; return }
107
    }
108
 
109
    # Accept it as an expected failure if gdb just fails to distinguish between
110
    # class and struct, and everything else is OK.
111
 
112
    setup_xfail_format "DWARF 1"
113
    send_gdb "ptype struct private_struct\n"
114
    gdb_expect {
115
        -re "type = struct private_struct \{${ws}private:${ws}int a;${ws}int b;$nl\}$nl$gdb_prompt $" {
116
            pass "ptype struct private_struct (FIXME)"
117
        }
118
        -re "type = class private_struct \{${ws}private:${ws}int a;${ws}int b;$nl.*\}$nl$gdb_prompt $" {
119
            setup_xfail "*-*-*"
120
            fail "ptype struct private_struct (FIXME)"
121
        }
122
        -re ".*$gdb_prompt $" { fail "ptype struct private_struct" }
123
        timeout { fail "ptype struct private_struct (timeout)" ; return }
124
    }
125
 
126
    # Accept it as an expected failure if gdb just fails to distinguish between
127
    # class and struct, and everything else is OK.
128
 
129
    setup_xfail_format "DWARF 1"
130
    send_gdb "ptype struct mixed_protection_struct\n"
131
    gdb_expect {
132
        -re "type = struct mixed_protection_struct \{${ws}int a;${ws}int b;${ws}private:${ws}int c;${ws}int d;${ws}protected:${ws}int e;${ws}int f;${ws}public:${ws}int g;${ws}private:${ws}int h;${ws}protected:${ws}int i;$nl\}$nl$gdb_prompt $" {
133
            pass "ptype struct mixed_protection_struct (FIXME)"
134
        }
135
        -re "type = struct mixed_protection_struct \{${ws}public:${ws}int a;${ws}int b;${ws}private:${ws}int c;${ws}int d;${ws}protected:${ws}int e;${ws}int f;${ws}public:${ws}int g;${ws}private:${ws}int h;${ws}protected:${ws}int i;$nl.*\}$nl$gdb_prompt $" {
136
            pass "ptype struct mixed_protection_struct (extra public)"
137
        }
138
        -re "type = class mixed_protection_struct \{${ws}public:${ws}int a;${ws}int b;${ws}private:${ws}int c;${ws}int d;${ws}protected:${ws}int e;${ws}int f;${ws}public:${ws}int g;${ws}private:${ws}int h;${ws}protected:${ws}int i;$nl.*\}$nl$gdb_prompt $" {
139
            setup_xfail "*-*-*"
140
            fail "ptype struct mixed_protection_struct (FIXME)"
141
        }
142
        -re ".*$gdb_prompt $" { fail "ptype struct mixed_protection_struct" }
143
        timeout { fail "ptype struct mixed_protection_struct (timeout)" ; return }
144
    }
145
 
146
    # Accept it as an expected failure if gdb just fails to distinguish between
147
    # class and struct, and everything else is OK.
148
 
149
    send_gdb "ptype class public_class\n"
150
    gdb_expect {
151
        -re "type = class public_class \{${ws}public:${ws}int a;${ws}int b;$nl.*\}$nl$gdb_prompt $" {
152
            pass "ptype class public_class (FIXME)"
153
        }
154
        -re "type = struct public_class \{${ws}int a;${ws}int b;$nl\}$nl$gdb_prompt $" {
155
            setup_xfail "*-*-*"
156
            fail "ptype class public_class (FIXME)"
157
        }
158
        -re ".*$gdb_prompt $" { fail "ptype class public_class" }
159
        timeout { fail "ptype class public_class (timeout)" ; return }
160
    }
161
 
162
    send_gdb "ptype class protected_class\n"
163
    gdb_expect {
164
        -re "type = class protected_class \{${ws}protected:${ws}int a;${ws}int b;$nl.*\}$nl$gdb_prompt $" {
165
            pass "ptype class protected_class"
166
        }
167
        -re "type = struct protected_class \{${ws}int a;${ws}int b;$nl\}$nl$gdb_prompt $" {
168
            setup_xfail "*-*-*"
169
            fail "ptype class protected_class"
170
        }
171
        -re ".*$gdb_prompt $" { fail "ptype class protected_class" }
172
        timeout { fail "ptype class protected_class (timeout)" ; return }
173
    }
174
 
175
    # Accept it as an expected failure if gdb just emits a superflous "private:"
176
    # attribute, since classes default to private and for consistency with
177
    # structs (where we don't print the "public:" attribute) we don't print
178
    # the "private:" attribute.
179
 
180
    setup_xfail_format "DWARF 1"
181
    send_gdb "ptype class default_private_class\n"
182
    gdb_expect {
183
        -re "type = class default_private_class \{${ws}int a;${ws}int b;$nl.*\}$nl$gdb_prompt $" {
184
            pass "ptype class default_private_class (FIXME)"
185
        }
186
        -re "type = class default_private_class \{${ws}private:${ws}int a;${ws}int b;$nl.*\}$nl$gdb_prompt $" {
187
            setup_xfail "*-*-*"
188
            fail "ptype class default_private_class (FIXME)"
189
        }
190
        -re ".*$gdb_prompt $" { fail "ptype class default_private_class" }
191
        timeout { fail "ptype class default_private_class (timeout)" ; return }
192
    }
193
 
194
    send_gdb "ptype class explicit_private_class\n"
195
    gdb_expect {
196
        -re "type = class explicit_private_class \{${ws}private:${ws}int a;${ws}int b;$nl.*\}$nl$gdb_prompt $" {
197
            pass "ptype class explicit_private_class"
198
        }
199
        -re "type = class explicit_private_class \{${ws}int a;${ws}int b;$nl.*\}$nl$gdb_prompt $" {
200
            pass "ptype class explicit_private_class (OK for HP aCC)"
201
        }
202
        -re "type = struct explicit_private_class \{${ws}int a;${ws}int b;$nl.*\}$nl$gdb_prompt $" {
203
            setup_xfail "*-*-*"
204
            fail "ptype class explicit_private_class"
205
        }
206
        -re ".*$gdb_prompt $" { fail "ptype class explicit_private_class" }
207
        timeout { fail "ptype class explicit_private_class (timeout)" ; return }
208
    }
209
 
210
    send_gdb "ptype class mixed_protection_class\n"
211
    gdb_expect {
212
        -re "type = class mixed_protection_class \{${ws}public:${ws}int a;${ws}int b;${ws}private:${ws}int c;${ws}int d;${ws}protected:${ws}int e;${ws}int f;${ws}public:${ws}int g;${ws}private:${ws}int h;${ws}protected:${ws}int i;$nl.*\}$nl$gdb_prompt $" {
213
            pass "ptype class mixed_protection_class"
214
        }
215
        -re "type = struct mixed_protection_class \{${ws}int a;${ws}int b;${ws}int c;${ws}int d;${ws}int e;${ws}int f;${ws}int g;${ws}int h;${ws}int i;$nl.*\}$nl$gdb_prompt $" {
216
            setup_xfail "*-*-*"
217
            fail "ptype class mixed_protection_class"
218
        }
219
        -re ".*$gdb_prompt $" { fail "ptype class mixed_protection_class" }
220
        timeout { fail "ptype class mixed_protection_class (timeout)" ; return }
221
    }
222
 
223
    # This class does not use any C++-specific features, so it's fine for
224
    # it to print as "struct".
225
    send_gdb "ptype class A\n"
226
    gdb_expect {
227
        -re "type = (class|struct) A \{(${ws}public:|)${ws}int a;${ws}int x;((${ws}A & operator=\\(A const ?&\\);)|(${ws}A\\((A const|const A) ?&\\);)|(${ws}A\\((void|)\\);))*${ws}\}$nl$gdb_prompt $" {
228
            pass "ptype class A"
229
        }
230
        -re ".*$gdb_prompt $" {
231
            fail "ptype class A"
232
        }
233
        timeout {
234
            fail "ptype class A (timeout)"
235
            return
236
        }
237
    }
238
 
239
    setup_xfail_format "DWARF 1"
240
    send_gdb "ptype class B\n"
241
    gdb_expect {
242
        -re "type = class B : public A \{${ws}public:${ws}int b;${ws}int x;${ws}B & operator=\\(B const ?&\\);${ws}B\\((B const|const B) ?&\\);${ws}B\\((void|)\\);${ws}\}$nl$gdb_prompt $" {
243
            pass "ptype class B"
244
        }
245
        -re "type = class B : public A \{${ws}public:${ws}int b;${ws}int x;((${ws}B & operator=\\(B const ?&\\);)|(${ws}B\\(B const ?&\\);)|(${ws}B\\((void|)\\);))*${ws}\}$nl$gdb_prompt $" {
246
            pass "ptype class B (obsolescent gcc or gdb)"
247
        }
248
        -re ".*$gdb_prompt $" {
249
            fail "ptype class B"
250
        }
251
        timeout {
252
            fail "ptype class B (timeout)"
253
            return
254
        }
255
    }
256
 
257
    setup_xfail_format "DWARF 1"
258
    send_gdb "ptype class C\n"
259
    gdb_expect {
260
        -re "type = class C : public A \{${ws}public:${ws}int c;${ws}int x;${ws}C & operator=\\(C const ?&\\);${ws}C\\((C const|const C) ?&\\);${ws}C\\((void|)\\);${ws}\}$nl$gdb_prompt $" {
261
            pass "ptype class C"
262
        }
263
        -re "type = class C : public A \{${ws}public:${ws}int c;${ws}int x;((${ws}C & operator=\\(C const ?&\\);)|(${ws}C\\(C const ?&\\);)|(${ws}C\\((void|)\\);))*${ws}\}$nl$gdb_prompt $" {
264
            pass "ptype class C (obsolescent gcc or gdb)"
265
        }
266
        -re ".*$gdb_prompt $" {
267
            fail "ptype class C"
268
        }
269
        timeout {
270
            fail "ptype class C (timeout)"
271
            return
272
        }
273
    }
274
 
275
    setup_xfail_format "DWARF 1"
276
    send_gdb "ptype class D\n"
277
    gdb_expect {
278
        -re "type = class D : public B, public C \{${ws}public:${ws}int d;${ws}int x;${ws}D & operator=\\(D const ?&\\);${ws}D\\((D const|const D) ?&\\);${ws}D\\((void|)\\);${ws}\}$nl$gdb_prompt $" {
279
            pass "ptype class D"
280
        }
281
        -re "type = class D : public B, public C \{${ws}public:${ws}int d;${ws}int x;((${ws}D & operator=\\(D const ?&\\);)|(${ws}D\\(D const ?&\\);)|(${ws}D\\((void|)\\);))*${ws}\}$nl$gdb_prompt $" {
282
            pass "ptype class D (obsolescent gcc or gdb)"
283
        }
284
        -re ".*$gdb_prompt $" {
285
            fail "ptype class D"
286
        }
287
        timeout {
288
            fail "ptype class D (timeout)"
289
            return
290
        }
291
    }
292
 
293
    setup_xfail_format "DWARF 1"
294
    send_gdb "ptype class E\n"
295
    gdb_expect {
296
        -re "type = class E : public D \{${ws}public:${ws}int e;${ws}int x;${ws}E & operator=\\(E const ?&\\);${ws}E\\((E const|const E) ?&\\);${ws}E\\((void|)\\);${ws}\}$nl$gdb_prompt $" {
297
            pass "ptype class E"
298
        }
299
        -re "type = class E : public D \{${ws}public:${ws}int e;${ws}int x;((${ws}E & operator=\\(E const ?&\\);)|(${ws}E\\((E const|const E) ?&\\);)|(${ws}E\\((void|)\\);))*${ws}\}$nl$gdb_prompt $" {
300
            pass "ptype class E"
301
        }
302
        -re ".*$gdb_prompt $" {
303
            fail "ptype class E"
304
        }
305
        timeout {
306
            fail "ptype class E (timeout)"
307
            return
308
        }
309
    }
310
 
311
    # With g++ 2.x and stabs debug info, we misinterpret static methods
312
    # whose name matches their argument mangling.
313
    send_gdb "ptype class Static\n"
314
    gdb_expect {
315
        -re "type = (class|struct) Static \{(${ws}public:|)${ws}Static & operator=\\(Static const ?&\\);${ws}Static\\((Static const|const Static) ?&\\);${ws}Static\\((void|)\\);${ws}static void ii\\(int, int\\);${ws}\}$nl$gdb_prompt $" {
316
            pass "ptype class Static"
317
        }
318
        -re "type = (class|struct) Static \{(${ws}public:|)${ws}static void ii\\(int, int\\);${ws}\}$nl$gdb_prompt $" {
319
            pass "ptype class Static"
320
        }
321
        -re ".*$gdb_prompt $" {
322
            fail "ptype class Static"
323
        }
324
        timeout {
325
            fail "ptype class Static (timeout)"
326
            return
327
        }
328
    }
329
 
330
    send_gdb "ptype class vA\n"
331
    gdb_expect {
332
        -re "type = (class|struct) vA \{(${ws}public:|)${ws}int va;${ws}int vx;${ws}\}$nl$gdb_prompt $" {
333
            pass "ptype class vA"
334
        }
335
        -re "type = (class|struct) vA \{(${ws}public:|)${ws}int va;${ws}int vx;${ws}vA & operator=\\(vA const ?&\\);${ws}vA\\((vA const|const vA) ?&\\);${ws}vA\\((void|)\\);${ws}\}$nl$gdb_prompt $" {
336
            pass "ptype class vA"
337
        }
338
        -re "type = (class|struct) vA \{(${ws}public:|)${ws}int va;${ws}int vx;((${ws}vA & operator=\\(vA const ?&\\);)|(${ws}vA\\(vA const ?&\\);)|(${ws}vA\\((void|)\\);))*${ws}\}$nl$gdb_prompt $" {
339
            pass "ptype class vA (obsolescent gcc or gdb)"
340
        }
341
        -re ".*$gdb_prompt $" {
342
            fail "ptype class vA"
343
        }
344
        timeout {
345
            fail "ptype class vA (timeout)"
346
            return
347
        }
348
    }
349
 
350
    # Accept the form with embedded GNU style mangled virtual table constructs
351
    # for now, but with a FIXME.  At some future point, gdb should use a
352
    # portable representation for the virtual table constructs.
353
 
354
    # The format of a g++ virtual base pointer.
355
    set vbptr "(_vb\[$.\]|__vb_)\[0-9\]?"
356
 
357
    setup_xfail_format "DWARF 1"
358
    send_gdb "ptype class vB\n"
359
    gdb_expect {
360
        -re "type = class vB : public virtual vA \{${ws}public:${ws}int vb;${ws}int vx;${ws}vB & operator=\\(vB const ?&\\);${ws}vB\\((vB const|const vB) ?&\\);${ws}vB\\((void|)\\);${ws}\}$nl$gdb_prompt $" {
361
            pass "ptype class vB"
362
        }
363
        -re "type = class vB : public virtual vA \{${ws}private:${ws}vA \\*${vbptr}vA;${ws}public:${ws}int vb;${ws}int vx;${ws}vB & operator=\\(vB const ?&\\);${ws}vB\\(int, vB const ?&\\);${ws}vB\\(int\\);${ws}\}$nl$gdb_prompt $" {
364
            setup_xfail "*-*-*"
365
            fail "ptype class vB (FIXME: non-portable virtual table constructs)"
366
        }
367
        -re "type = class vB : public virtual vA \{${ws}public:${ws}int vb;${ws}int vx;${ws}\}$nl$gdb_prompt $" {
368
            pass "ptype class vB"
369
        }
370
        -re "type = class vB : public virtual vA \{${ws}private:${ws}vA \\*_vb.vA;${ws}public:${ws}int vb;${ws}int vx;((${ws}vB & operator=\\(vB const ?&\\);)|(${ws}vB\\(int, vB const ?&\\);)|(${ws}vB\\(int\\);))*${ws}\}$nl$gdb_prompt $" {
371
            setup_xfail "*-*-*"
372
            fail "ptype class vB (FIXME) (obsolescent gcc or gdb)"
373
        }
374
        -re ".*$gdb_prompt $" {
375
            fail "ptype class vB"
376
        }
377
        timeout {
378
            fail "ptype class vB (timeout)"
379
            return
380
        }
381
    }
382
 
383
    # Accept the form with embedded GNU style mangled virtual table constructs
384
    # for now, but with a FIXME.  At some future point, gdb should use a
385
    # portable representation for the virtual table constructs.
386
 
387
    setup_xfail_format "DWARF 1"
388
    send_gdb "ptype class vC\n"
389
    gdb_expect {
390
        -re "type = class vC : public virtual vA \{${ws}public:${ws}int vc;${ws}int vx;${ws}vC & operator=\\(vC const ?&\\);${ws}vC\\((vC const|const vC) ?&\\);${ws}vC\\((void|)\\);${ws}\}$nl$gdb_prompt $" {
391
            pass "ptype class vC"
392
        }
393
        -re "type = class vC : public virtual vA \{${ws}private:${ws}vA \\*${vbptr}vA;${ws}public:${ws}int vc;${ws}int vx;${ws}vC & operator=\\(vC const ?&\\);${ws}vC\\(int, vC const ?&\\);${ws}vC\\(int\\);${ws}\}$nl$gdb_prompt $" {
394
            setup_xfail "*-*-*"
395
            fail "ptype class vC (FIXME: non-portable virtual table constructs)"
396
        }
397
        -re "type = class vC : public virtual vA \{${ws}public:${ws}int vc;${ws}int vx;${ws}\}$nl$gdb_prompt $" {
398
            pass "ptype class vC"
399
        }
400
        -re "type = class vC : public virtual vA \{${ws}private:${ws}vA \\*_vb.vA;${ws}public:${ws}int vc;${ws}int vx;((${ws}vC & operator=\\(vC const ?&\\);)|(${ws}vC\\(int, vC const ?&\\);)|(${ws}vC\\(int\\);))*${ws}\}$nl$gdb_prompt $" {
401
            setup_xfail "*-*-*"
402
            fail "ptype class vC (FIXME) (obsolescent gcc or gdb)"
403
        }
404
        -re ".*$gdb_prompt $" {
405
            fail "ptype class vC"
406
        }
407
        timeout {
408
            fail "ptype class vC (timeout)"
409
            return
410
        }
411
    }
412
 
413
    # Accept the form with embedded GNU style mangled virtual table constructs
414
    # for now, but with a FIXME.  At some future point, gdb should use a
415
    # portable representation for the virtual table constructs.
416
 
417
    setup_xfail_format "DWARF 1"
418
    send_gdb "ptype class vD\n"
419
    gdb_expect {
420
        -re "type = class vD : public virtual vB, public virtual vC \{${ws}public:${ws}int vd;${ws}int vx;${ws}vD & operator=\\(vD const ?&\\);${ws}vD\\((vD const|const vD) ?&\\);${ws}vD\\((void|)\\);${ws}\}$nl$gdb_prompt $" {
421
            pass "ptype class vD"
422
        }
423
        -re "type = class vD : public virtual vB, public virtual vC \{${ws}private:${ws}vC \\*${vbptr}vC;${ws}vB \\*${vbptr}vB;${ws}public:${ws}int vd;${ws}int vx;${ws}vD & operator=\\(vD const ?&\\);${ws}vD\\(int, vD const ?&\\);${ws}vD\\(int\\);${ws}\}$nl$gdb_prompt $" {
424
            setup_xfail "*-*-*"
425
            fail "ptype class vD (FIXME: non-portable virtual table constructs)"
426
        }
427
        -re "type = class vD : public virtual vB, public virtual vC \{${ws}public:${ws}int vd;${ws}int vx;${ws}\}$nl$gdb_prompt $" {
428
            pass "ptype class vD"
429
        }
430
        -re "type = class vD : public virtual vB, public virtual vC \{${ws}private:${ws}vC \\*_vb.vC;${ws}vB \\*_vb.vB;${ws}public:${ws}int vd;${ws}int vx;((${ws}vD & operator=\\(vD const ?&\\);)|(${ws}vD\\(int, vD const ?&\\);)|(${ws}vD\\(int\\);))*${ws}\}$nl$gdb_prompt $" {
431
            setup_xfail "*-*-*"
432
            fail "ptype class vD (FIXME) (obsolescent gcc or gdb)"
433
        }
434
        -re ".*$gdb_prompt $" {
435
            fail "ptype class vD"
436
        }
437
        timeout {
438
            fail "ptype class vD (timeout)"
439
            return
440
        }
441
    }
442
 
443
    # Accept the form with embedded GNU style mangled virtual table constructs
444
    # for now, but with a FIXME.  At some future point, gdb should use a
445
    # portable representation for the virtual table constructs.
446
 
447
    setup_xfail_format "DWARF 1"
448
    send_gdb "ptype class vE\n"
449
    gdb_expect {
450
        -re "type = class vE : public virtual vD \{${ws}public:${ws}int ve;${ws}int vx;${ws}vE & operator=\\(vE const ?&\\);${ws}vE\\((vE const|const vE) ?&\\);${ws}vE\\((void|)\\);${ws}\}$nl$gdb_prompt $" {
451
            pass "ptype class vE"
452
        }
453
        -re "type = class vE : public virtual vD \{${ws}private:${ws}vD \\*${vbptr}vD;${ws}public:${ws}int ve;${ws}int vx;${ws}vE & operator=\\(vE const ?&\\);${ws}vE\\(int, vE const ?&\\);${ws}vE\\(int\\);${ws}\}$nl$gdb_prompt $" {
454
            setup_xfail "*-*-*"
455
            fail "ptype class vE (FIXME: non-portable virtual table constructs)"
456
        }
457
        -re "type = class vE : public virtual vD \{${ws}public:${ws}int ve;${ws}int vx;${ws}\}$nl$gdb_prompt $" {
458
            pass "ptype class vE"
459
        }
460
        -re "type = class vE : public virtual vD \{${ws}private:${ws}vD \\*_vb.vD;${ws}public:${ws}int ve;${ws}int vx;((${ws}vE & operator=\\(vE const ?&\\);)|(${ws}vE\\(int, vE const ?&\\);)|(${ws}vE\\(int\\);))*${ws}\}$nl$gdb_prompt $" {
461
            setup_xfail "*-*-*"
462
            fail "ptype class vE (FIXME) (obsolescent gcc or gdb)"
463
        }
464
        -re ".*$gdb_prompt $" {
465
            fail "ptype class vE"
466
        }
467
        timeout {
468
            fail "ptype class vE (timeout)"
469
            return
470
        }
471
    }
472
 
473
    setup_xfail_format "DWARF 1"
474
    send_gdb "ptype class Base1\n"
475
    gdb_expect {
476
        -re "type = class Base1 \{${ws}public:${ws}int x;${ws}Base1 & operator=\\(Base1 const ?&\\);${ws}Base1\\(((Base1 const)|(const Base1)) ?&\\);${ws}Base1\\(int\\);${ws}\}$nl$gdb_prompt $" {
477
            pass "ptype class Base1"
478
        }
479
        -re "type = class Base1 \{${ws}public:${ws}int x;${ws}Base1\\(int\\);${ws}\}$nl$gdb_prompt $" {
480
            pass "ptype class Base1"
481
        }
482
        -re "type = class Base1 \{${ws}public:${ws}int x;((${ws}Base1 & operator=\\(Base1 const ?&\\);)|(${ws}Base1\\(Base1 const ?&\\);)|(${ws}Base1\\(int\\);))*${ws}\}$nl$gdb_prompt $" {
483
            pass "ptype class Base1 (obsolescent gcc or gdb)"
484
        }
485
        -re ".*$gdb_prompt $" {
486
            fail "ptype class Base1"
487
        }
488
        timeout {
489
            fail "ptype class Base1 (timeout)"
490
            return
491
        }
492
    }
493
 
494
    setup_xfail_format "DWARF 1"
495
    send_gdb "ptype class Foo\n"
496
    gdb_expect {
497
        -re "type = class Foo \{${ws}public:${ws}int x;${ws}int y;${ws}static int st;\r\n${ws}Foo\\(int, int\\);${ws}int operator!\\((void|)\\);${ws}operator int\\((void|)\\);${ws}int times\\(int\\);$nl\}$nl$gdb_prompt $" {
498
            pass "ptype class Foo"
499
        }
500
        -re "type = class Foo \{${ws}public:${ws}int x;${ws}int y;${ws}static int st;${ws}Foo & operator=\\(Foo const ?&\\);${ws}Foo\\((Foo const|const Foo) ?&\\);${ws}Foo\\(int, int\\);${ws}int operator!\\((void|)\\);${ws}operator int\\((void|)\\);${ws}int times\\(int\\);${ws}\}$nl$gdb_prompt $" {
501
            pass "ptype class Foo"
502
        }
503
        -re "type = class Foo \{${ws}public:${ws}int x;${ws}int y;${ws}static int st;((${ws}Foo & operator=\\(Foo const ?&\\);)|(${ws}Foo\\(Foo const ?&\\);)|(${ws}Foo\\(int, int\\);)|(${ws}int operator!\\((void|)\\);)|(${ws}int operator int\\((void|)\\);)|(${ws}int times\\(int\\);))*${ws}\}$nl$gdb_prompt $" {
504
            pass "ptype class Foo (obsolescent gcc or gdb)"
505
        }
506
        -re ".*$gdb_prompt $" {
507
            fail "ptype class Foo"
508
        }
509
        timeout {
510
            fail "ptype class Foo (timeout)"
511
            return
512
        }
513
    }
514
 
515
    setup_xfail_format "DWARF 1"
516
    send_gdb "ptype class Bar\n"
517
    gdb_expect {
518
        -re "type = class Bar : public Base1, public Foo \{${ws}public:${ws}int z;${ws}Bar & operator=\\(Bar const ?&\\);${ws}Bar\\((Bar const|const Bar) ?&\\);${ws}Bar\\(int, int, int\\);${ws}\}$nl$gdb_prompt $" {
519
            pass "ptype class Bar"
520
        }
521
        -re "type = class Bar : public Base1, public Foo \{${ws}public:${ws}int z;((${ws}Bar & operator=\\(Bar const ?&\\);)|(${ws}Bar\\(Bar const ?&\\);)|(${ws}Bar\\(int, int, int\\);))*${ws}\}$nl$gdb_prompt $" {
522
            pass "ptype class Bar (obsolescent gcc or gdb)"
523
        }
524
        -re ".*$gdb_prompt $" {
525
            fail "ptype class Bar"
526
        }
527
        timeout {
528
            fail "ptype class Bar (timeout)"
529
            return
530
        }
531
    }
532
}
533
 
534
#
535
# Test simple access to class members.
536
#
537
 
538
proc test_non_inherited_member_access {} {
539
    global gdb_prompt
540
 
541
    # Print non-inherited members of g_A.
542
 
543
    gdb_test "print g_A.a" ".* = 1" "g_A.a incorrect"
544
 
545
    gdb_test "print g_A.x" ".* = 2" "g_A.x incorrect"
546
 
547
    # Print non-inherited members of g_B.
548
 
549
    gdb_test "print g_B.b" ".* = 5" "g_B.b incorrect"
550
 
551
    gdb_test "print g_B.x" ".* = 6" "g_B.x incorrect"
552
 
553
    # Print non-inherited members of g_C.
554
 
555
    gdb_test "print g_C.c" ".* = 9" "g_C.c incorrect"
556
 
557
    gdb_test "print g_C.x" ".* = 10" "g_C.x incorrect"
558
 
559
    # Print non-inherited members of g_D.
560
 
561
    gdb_test "print g_D.d" ".* = 19" "g_D.d incorrect"
562
 
563
    gdb_test "print g_D.x" ".* = 20" "g_D.x incorrect"
564
 
565
    # Print non-inherited members of g_E.
566
 
567
    gdb_test "print g_E.e" ".* = 31" "g_E.e incorrect"
568
 
569
    gdb_test "print g_E.x" ".* = 32" "g_E.x incorrect"
570
}
571
 
572
#
573
# Try access to non-members that are members of another class.
574
# Should give errors.
575
#
576
 
577
proc test_wrong_class_members {} {
578
    global gdb_prompt
579
 
580
    gdb_test "print g_A.b" "There is no member( or method|) named b." "print g_A.b should be error"
581
 
582
    gdb_test "print g_B.c" "There is no member( or method|) named c." "print g_B.c should be error"
583
 
584
    gdb_test "print g_B.d" "There is no member( or method|) named d." "print g_B.d should be error"
585
 
586
    gdb_test "print g_C.b" "There is no member( or method|) named b." "print g_C.b should be error"
587
 
588
    gdb_test "print g_C.d" "There is no member( or method|) named d." "print g_C.d should be error"
589
 
590
    gdb_test "print g_D.e" "There is no member( or method|) named e." "print g_D.e should be error"
591
}
592
 
593
#
594
# Try access to non-members that are not members of any class.
595
# Should give errors.
596
#
597
 
598
proc test_nonexistent_members {} {
599
    global gdb_prompt
600
 
601
    gdb_test "print g_A.y" "There is no member( or method|) named y." "print g_A.y should be error"
602
 
603
    gdb_test "print g_B.z" "There is no member( or method|) named z." "print g_B.z should be error"
604
 
605
    gdb_test "print g_C.q" "There is no member( or method|) named q." "print g_C.q should be error"
606
 
607
    gdb_test "print g_D.p" "There is no member( or method|) named p." "print g_D.p should be error"
608
}
609
 
610
#
611
# Call a method that expects a base class parameter with base, inherited,
612
# and unrelated class arguments.
613
#
614
 
615
proc test_method_param_class {} {
616
    gdb_test "call class_param.Aptr_a (&g_A)" ".* = 1" "base class param->a"
617
    gdb_test "call class_param.Aptr_x (&g_A)" ".* = 2" "base class param->x"
618
    gdb_test "call class_param.Aptr_a (&g_B)" ".* = 3" "inherited class param->a"
619
    gdb_test "call class_param.Aptr_x (&g_B)" ".* = 4" "inherited class param->x"
620
    gdb_test "call class_param.Aref_a (g_A)" ".* = 1" "base class (¶m)->a"
621
    gdb_test "call class_param.Aref_x (g_A)" ".* = 2" "base class (¶m)->x"
622
    gdb_test "call class_param.Aref_a (g_B)" ".* = 3" "inherited class (¶m)->a"
623
    gdb_test "call class_param.Aref_x (g_B)" ".* = 4" "inherited class (¶m)->x"
624
    gdb_test "call class_param.Aval_a (g_A)" ".* = 1" "base class param.a"
625
    gdb_test "call class_param.Aval_x (g_A)" ".* = 2" "base class param.x"
626
    gdb_test "call class_param.Aval_a (g_B)" ".* = 3" "inherited class param.a"
627
    gdb_test "call class_param.Aval_x (g_B)" ".* = 4" "inherited class param.x"
628
 
629
    gdb_test "call class_param.Aptr_a (&foo)" "Cannot resolve .*" "unrelated class *param"
630
    gdb_test "call class_param.Aref_a (foo)" "Cannot resolve .*" "unrelated class ¶m"
631
    gdb_test "call class_param.Aval_a (foo)" "Cannot resolve .*" "unrelated class param"
632
}
633
 
634
#
635
# Examine a class with an enum field.
636
#
637
 
638
proc test_enums {} {
639
    global gdb_prompt
640
    global hp_aCC_compiler
641
 
642
    # print the object
643
    send_gdb "print obj_with_enum\n"
644
    gdb_expect {
645
        -re "\\$\[0-9\]* = \\{priv_enum = red, x = 0\\}.*$gdb_prompt $" { pass "print obj_with_enum (1)" }
646
        -re "$gdb_prompt $"                     { fail "print obj_with_enum (1)" }
647
        timeout                             { fail "(timeout) print obj_with_enum (1)" }
648
    }
649
 
650
    send_gdb "next\n"
651
    gdb_expect {
652
        -re "$gdb_prompt $"                     { pass "next" }
653
        timeout                             { fail "(timeout) next" }
654
    }
655
 
656
    # print the object again
657
    send_gdb "print obj_with_enum\n"
658
    gdb_expect {
659
        -re "\\$\[0-9\]* = \\{priv_enum = green, x = 0\\}.*$gdb_prompt $" { pass "print obj_with_enum (2)" }
660
        -re "$gdb_prompt $"                     { fail "print obj_with_enum (2)" }
661
        timeout                             { fail "(timeout) print obj_with_enum (2)" }
662
    }
663
 
664
    # print out the enum member
665
    send_gdb "print obj_with_enum.priv_enum\n"
666
    gdb_expect {
667
        -re "\\$\[0-9\]* = green.*$gdb_prompt $" { pass "print obj_with_enum.priv_enum" }
668
        -re "$gdb_prompt $"                     { fail "print obj_with_enum.priv_enum" }
669
        timeout                             { fail "(timeout) print obj_with_enum.priv_enum" }
670
    }
671
 
672
    # ptype on the enum member
673
    # The third success case is a little dubious, but it's not clear what
674
    # ought to be required of a ptype on a private enum... -sts 19990324
675
    send_gdb "ptype obj_with_enum.priv_enum\n"
676
    gdb_expect {
677
        -re "type = enum ClassWithEnum::PrivEnum \\{red, green, blue, yellow = 42\\}.*$gdb_prompt $" { pass "ptype obj_with_enum.priv_enum" }
678
        -re "type = enum PrivEnum \\{red, green, blue, yellow = 42\\}.*$gdb_prompt $" { pass "ptype obj_with_enum.priv_enum" }
679
        -re "type = enum \\{red, green, blue, yellow = 42\\}.*$gdb_prompt $" { pass "ptype obj_with_enum.priv_enum" }
680
        -re "$gdb_prompt $"                     { fail "ptype obj_with_enum.priv_enum" }
681
        timeout                             { fail "(timeout) ptype obj_with_enum.priv_enum" }
682
    }
683
 
684
    # ptype on the object
685
    # g++ is putting out the wrong debug info.  This works with aCC
686
    if {!$hp_aCC_compiler} {setup_xfail "*-*-*"}
687
    send_gdb "ptype obj_with_enum\n"
688
    gdb_expect {
689
        -re "type = class ClassWithEnum \\{\r\n\[ \t\]*public:\r\n\[ \t\]*(enum |)ClassWithEnum::PrivEnum priv_enum;\r\n\[ \t\]*int x;\r\n\\}\r\n$gdb_prompt $" { pass "ptype obj_with_enum" }
690
        -re "$gdb_prompt $"                     { fail "ptype obj_with_enum" }
691
        timeout                             { fail "(timeout) ptype obj_with_enum" }
692
    }
693
 
694
    # g++ is putting out the wrong debug info.  This works with aCC
695
    if {!$hp_aCC_compiler} {setup_xfail "*-*-*"}
696
    send_gdb "print (ClassWithEnum::PrivEnum) 42\n"
697
    gdb_expect {
698
        -re "\\$\[0-9\]* = yellow.*$gdb_prompt $" { pass "print (ClassWithEnum::PrivEnum) 42" }
699
        -re "$gdb_prompt $"                     { fail "print (ClassWithEnum::PrivEnum) 42" }
700
        timeout                             { fail "(timeout) print (ClassWithEnum::PrivEnum) 42" }
701
    }
702
}
703
 
704
#
705
# Pointers to class members
706
#
707
 
708
proc test_pointers_to_class_members {} {
709
    global gdb_prompt
710
    global decimal
711
    global nl
712
 
713
    gdb_test "print Bar::z" ".* = .int\[ \]*\[( \]*Bar::&\[)\]+\[ \]*Bar::z" "print Bar::z"
714
 
715
    gdb_test "print &Foo::x" ".* = .int\[ \]*\[( \]*Foo::\[*)\]+\[ \]*&Foo::x" "print &Foo::x"
716
 
717
    gdb_test "print (int)&Foo::x" ".* = 0" "print (int)&Foo::x"
718
 
719
    send_gdb "print (int)&Bar::y == 2*sizeof(int)\n"
720
    gdb_expect {
721
        -re ".* = true$nl$gdb_prompt $" {
722
            pass "print (int)&Bar::y == 2*sizeof(int)"
723
        }
724
        -re "There is no field named y.*$gdb_prompt $" {
725
            setup_xfail "*-*-*"
726
            fail "print (int)&Bar::y == 2*sizeof(int)"
727
        }
728
        -re ".*$gdb_prompt $" { fail "print (int)&Bar::y == 2*sizeof(int)" }
729
        timeout { fail "print (int)&Bar::y == 2*sizeof(int) (timeout)" ; return }
730
    }
731
 
732
    send_gdb "next 2\n"
733
    setup_xfail "*-*-*"
734
    gdb_expect {
735
        -re "$decimal\[ \t\]+inheritance3 \[)(\]+;$nl$gdb_prompt $" {}
736
        -re ".*$gdb_prompt $" { fail "next to inheritance3" ; return }
737
    }
738
    clear_xfail "*-*-*"
739
 
740
    setup_xfail_format "DWARF 1"
741
    gdb_test "print (int)pmi == sizeof(int)" ".* = false" "print (int)pmi == sizeof(int)"
742
}
743
 
744
#
745
# Test static members.
746
#
747
 
748
proc test_static_members {} {
749
    global gdb_prompt
750
    global hex
751
    global nl
752
 
753
    send_gdb "print Foo::st\n"
754
    gdb_expect {
755
        -re ".* = 100$nl$gdb_prompt $" {
756
            pass "print Foo::st"
757
        }
758
        -re "There is no field named st.*$gdb_prompt $" {
759
            setup_xfail "*-*-*"
760
            fail "print Foo::st"
761
        }
762
        -re ".*$gdb_prompt $" { fail "print Foo::st" }
763
       timeout { fail "print Foo::st (timeout)" ; return }
764
    }
765
 
766
    send_gdb "set foo.st = 200\n"
767
    gdb_expect {
768
        -re ".*$gdb_prompt $" {}
769
    }
770
 
771
    send_gdb "print bar.st\n"
772
    gdb_expect {
773
        -re ".* = 200$nl$gdb_prompt $" {
774
            pass "print bar.st"
775
        }
776
        -re "There is no member( or method|) named st.*$gdb_prompt $" {
777
            setup_xfail "*-*-*"
778
            fail "print bar.st"
779
        }
780
        -re ".*$gdb_prompt $" { fail "print bar.st" }
781
       timeout { fail "print bar.st (timeout)" ; return }
782
    }
783
 
784
    send_gdb "print &foo.st\n"
785
    gdb_expect {
786
        -re ".* = .int \[*)\]+ $hex$nl$gdb_prompt $" {
787
            pass "print &foo.st"
788
        }
789
        -re "There is no member( or method|) named st.*$gdb_prompt $" {
790
            setup_xfail "*-*-*"
791
            fail "print &foo.st"
792
        }
793
        -re ".*$gdb_prompt $" { fail "print &foo.st" }
794
       timeout { fail "print &foo.st (timeout)" ; return }
795
    }
796
 
797
    set got_bar_st 0
798
    send_gdb "print &Bar::st\n"
799
    gdb_expect {
800
        -re ".* = .int \[*)\]+ $hex$nl$gdb_prompt $" {
801
            pass "print &Bar::st"
802
            set got_bar_st 1
803
        }
804
        -re "There is no field named st.*$gdb_prompt $" {
805
            setup_xfail "*-*-*"
806
            fail "print &Bar::st"
807
        }
808
        -re ".*$gdb_prompt $" { fail "print &Bar::st" }
809
       timeout { fail "print &Bar::st (timeout)" ; return }
810
    }
811
 
812
    if $got_bar_st then {
813
        gdb_test "print *\$" ".* = 200" "print *\$"
814
    }
815
 
816
    gdb_test "set print static-members off" ""
817
    gdb_test "print csi" \
818
        "{x = 10, y = 20}" \
819
        "print csi without static members"
820
    gdb_test "print cnsi" \
821
        "{x = 30, y = 40}" \
822
        "print cnsi without static members"
823
 
824
    gdb_test "set print static-members on" ""
825
    setup_xfail_format "DWARF 1"
826
    gdb_test "print csi" \
827
        "{x = 10, y = 20, static null = {x = 0, y = 0, static null = }}" \
828
        "print csi with static members"
829
    setup_xfail_format "DWARF 1"
830
    gdb_test "print cnsi" \
831
        "{x = 30, y = 40, static null = {x = 0, y = 0, static null = , static yy = {z = 5, static xx = {x = 1, y = 2, static null = , static yy = }}}, static yy = }" \
832
        "print cnsi with static members"
833
}
834
 
835
proc do_tests {} {
836
    global prms_id
837
    global bug_id
838
    global subdir
839
    global objdir
840
    global srcdir
841
    global binfile
842
    global gdb_prompt
843
 
844
    set prms_id 0
845
    set bug_id 0
846
 
847
    # Start with a fresh gdb.
848
 
849
    gdb_exit
850
    gdb_start
851
    gdb_reinitialize_dir $srcdir/$subdir
852
    gdb_load $binfile
853
 
854
    send_gdb "set language c++\n"
855
    gdb_expect -re "$gdb_prompt $"
856
    send_gdb "set width 0\n"
857
    gdb_expect -re "$gdb_prompt $"
858
 
859
    # Get the debug format for the compiled test case.
860
 
861
    if [ runto_main ] then {
862
        get_debug_format
863
    }
864
 
865
    test_ptype_class_objects
866
 
867
    if [ runto 'inheritance2' ] then {
868
        test_non_inherited_member_access
869
        test_wrong_class_members
870
        test_nonexistent_members
871
        test_method_param_class
872
    }
873
 
874
    gdb_breakpoint enums2
875
    if [ gdb_continue "enums2(\\(\\)|)" ]==0 then {
876
        gdb_test "finish" "" ""
877
        test_enums
878
    }
879
 
880
    if [istarget "mips-idt-*"] then {
881
        # Restart because IDT/SIM runs out of file descriptors.
882
        gdb_exit
883
        gdb_start
884
        gdb_reinitialize_dir $srcdir/$subdir
885
        gdb_load $binfile
886
    }
887
 
888
    if [ runto_main ] then {
889
        test_pointers_to_class_members
890
        test_static_members
891
    }
892
 
893
    if [istarget "mips-idt-*"] then {
894
        # Restart because IDT/SIM runs out of file descriptors.
895
        gdb_exit
896
        gdb_start
897
        gdb_reinitialize_dir $srcdir/$subdir
898
        gdb_load $binfile
899
    }
900
 
901
    if [ runto marker_reg1 ] then {
902
 
903
        gdb_test "finish" "Run till exit from.*" "finish from marker_reg1"
904
 
905
        send_gdb "print v.method ()\n"
906
        gdb_expect {
907
            -re "= 82.*$gdb_prompt $" {
908
                pass "calling method for small class"
909
            }
910
            -re "Address requested for identifier .v. which is in register.*$gdb_prompt $" {
911
                setup_xfail "*-*-*" 2972
912
                fail "calling method for small class"
913
            }
914
            -re ".*$gdb_prompt $" { fail "calling method for small class" }
915
            timeout { fail "calling method for small class (timeout)" }
916
            eof { fail "calling method for small class (eof)" }
917
        }
918
    }
919
 
920
}
921
 
922
do_tests
923
 
924
send_gdb "maint demangle inheritance1__Fv\n"
925
gdb_expect {
926
   -re "inheritance1\\(void\\).*$gdb_prompt $" { pass "demangle" }
927
   -re ".*$gdb_prompt $"   { fail "demangle" }
928
   timeout           { fail "(timeout) demangle" }
929
}

powered by: WebSVN 2.1.0

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