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