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

Subversion Repositories openrisc

[/] [openrisc/] [tags/] [gnu-src/] [gdb-7.2/] [gdb-7.2-or32-1.0rc1/] [gdb/] [testsuite/] [gdb.cp/] [cpexprs.exp] - Blame information for rev 779

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

Line No. Rev Author Line
1 330 jeremybenn
# cpexprs.exp - C++ expressions tests
2
#
3
# Copyright 2008, 2009, 2010 Free Software Foundation, Inc.
4
#
5
# Contributed by Red Hat, originally written by Keith Seitz.
6
#
7
# This program is free software; you can redistribute it and/or modify
8
# it under the terms of the GNU General Public License as published by
9
# the Free Software Foundation; either version 3 of the License, or
10
# (at your option) any later version.
11
#
12
# This program is distributed in the hope that it will be useful,
13
# but WITHOUT ANY WARRANTY; without even the implied warranty of
14
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
# GNU General Public License for more details.
16
#
17
# You should have received a copy of the GNU General Public License
18
# along with this program.  If not, see .
19
 
20
# This file is part of the gdb testsuite.
21
 
22
# A helper proc which sets a breakpoint at FUNC and attempts to
23
# run to the breakpoint.
24
proc test_breakpoint {func} {
25
    global DEC
26
 
27
    # Restart every time
28
    if {![runto_main]} {
29
        perror "could not run to main when attempting to break at $func"
30
    } else {
31
        gdb_breakpoint "$func"
32
        set i [expr {[string last : $func] + 1}]
33
        set efunc [string_to_regexp [string range $func $i end]]
34
        gdb_test "continue" \
35
            "Continuing.\r\n\r\nBreakpoint $DEC+,.*$efunc.*" \
36
            "continue to $func"
37
    }
38
}
39
 
40
# Add a function to the list of tested functions
41
# FUNC is the name of the function (which will be passed to gdb commands)
42
# TYPE is the type of the function, as expected from the "print" command
43
# PRINT is the name of the function, as expected result of the print command
44
#  *OR* "-", indicating that FUNC should be used (needed for virtual/inherited
45
#   funcs)
46
# LST is either the expected result of the list command (the comment from
47
#  the source code) *OR* "-", in which case FUNC will be used
48
#
49
# Usage:
50
# add NAME TYPE PRINT LST
51
# add NAME TYPE PRINT -
52
proc add {func type print lst} {
53
    global all_functions CONVAR ADDR
54
 
55
    set all_functions($func,type) $type
56
    if {$print == "-"} {
57
        set print $func
58
    }
59
 
60
    # An exception: since gdb canonicalizes C++ output,
61
    # "(void)" must be mutated to "()".
62
    regsub {\(void\)} $print {()} print
63
 
64
    set all_functions($func,print) \
65
        "$CONVAR = {[string_to_regexp $type]} $ADDR <[string_to_regexp $print].*>"
66
    if {$lst == "-"} {
67
        set lst "$func"
68
    }
69
    set all_functions($func,list) ".*// [string_to_regexp $lst]"
70
}
71
 
72
proc get {func cmd} {
73
    global all_functions
74
    return $all_functions($func,$cmd)
75
}
76
 
77
# Returns a list of function names for a given command
78
proc get_functions {cmd} {
79
    global all_functions
80
    set result {}
81
    foreach i [array names all_functions *,$cmd] {
82
        if {$all_functions($i) != ""} {
83
            set idx [string last , $i]
84
            if {$idx != -1} {
85
                lappend result [string range $i 0 [expr {$idx - 1}]]
86
            }
87
        }
88
    }
89
 
90
    return [lsort $result]
91
}
92
 
93
# Some convenience variables for this test
94
set DEC {[0-9]}; # a decimal number
95
set HEX {[0-9a-fA-F]}; # a hexidecimal number
96
set CONVAR "\\\$$DEC+"; # convenience variable regexp
97
set ADDR "0x$HEX+"; # address
98
 
99
# An array of functions/methods that we are testing...
100
# Each element consists is indexed by NAME,COMMAND, where
101
# NAME is the function name and COMMAND is the gdb command that
102
# we are testing. The value of the array for any index pair is
103
# the expected result of running COMMAND with the NAME as argument.
104
 
105
# The array holding all functions/methods to test. Valid subindexes
106
# are (none need character escaping -- "add" will take care of that):
107
 
108
# add name type print_name list
109
# NAME,type: value is type of function
110
# NAME,print: value is print name of function (careful w/inherited/virtual!)
111
# NAME,list: value is comment in source code on first line of function
112
#   (without the leading "//")
113
array set all_functions {}
114
 
115
# "Normal" functions/methods
116
add {main} \
117
    {int (int, char **)} \
118
    - \
119
    -
120
add {derived::a_function} \
121
    {void (const derived * const)} \
122
    - \
123
    -
124
add {base1::a_function} \
125
    {void (const base1 * const)} \
126
    - \
127
    -
128
add {base2::a_function} \
129
    {void (const base2 * const)} \
130
    - \
131
    -
132
 
133
# Constructors
134
 
135
# On targets using the ARM EABI, the constructor is expected to return
136
# "this".
137
proc ctor { type arglist } {
138
    if { [istarget arm*-*eabi*] } {
139
        set ret "$type *"
140
    } else {
141
        set ret "void "
142
    }
143
    if { $arglist != "" } {
144
        set arglist ", $arglist"
145
    }
146
    return "${ret}($type * const$arglist)"
147
}
148
 
149
add {derived::derived} \
150
    [ctor derived ""] \
151
    - \
152
    -
153
add {base1::base1(void)} \
154
    [ctor base1 "const void ** const"] \
155
    - \
156
    -
157
add {base1::base1(int)} \
158
    [ctor base1 "int"] \
159
    - \
160
    -
161
add {base2::base2} \
162
    [ctor base2 "const void ** const"] \
163
    - \
164
    -
165
add {base::base(void)} \
166
    [ctor base ""] \
167
    - \
168
    -
169
add {base::base(int)} \
170
    [ctor base "int"] \
171
    - \
172
    -
173
 
174
# Destructors
175
 
176
# On targets using the ARM EABI, some destructors are expected
177
# to return "this".  Others are void.  For internal reasons,
178
# GCC returns void * instead of $type *; RealView appears to do
179
# the same.
180
proc dtor { type } {
181
    if { [istarget arm*-*eabi*] } {
182
        set ret "void *"
183
    } else {
184
        set ret "void "
185
    }
186
    return "${ret}($type * const)"
187
}
188
 
189
add {base::~base} \
190
    [dtor base] \
191
    - \
192
    -
193
 
194
# Overloaded methods (all are const -- we try to use the void
195
# method with and without specifying "const")
196
add {base::overload(void)} \
197
    {int (const base * const)} \
198
    - \
199
    {base::overload(void) const}
200
add {base::overload(void) const} \
201
    {int (const base * const)} \
202
    - \
203
    {base::overload(void) const}
204
add {base::overload(int) const} \
205
    {int (const base * const, int)} \
206
    - \
207
    -
208
add {base::overload(short) const} \
209
    {int (const base * const, short)} \
210
    - \
211
    -
212
add {base::overload(long) const} \
213
    {int (const base * const, long)} \
214
    - \
215
    -
216
add {base::overload(char*) const} \
217
    {int (const base * const, char *)} \
218
    - \
219
    -
220
add {base::overload(base&) const} \
221
    {int (const base * const, base &)} \
222
    - \
223
    -
224
 
225
# Operators
226
add {base::operator+} \
227
    {int (const base * const, const base &)} \
228
    - \
229
    -
230
add {base::operator++} \
231
    {base (base * const)} \
232
    - \
233
    -
234
add {base::operator+=} \
235
    {base (base * const, const base &)} \
236
    - \
237
    -
238
add {base::operator-} \
239
    {int (const base * const, const base &)} \
240
    - \
241
    -
242
add {base::operator--} \
243
    {base (base * const)} \
244
    - \
245
    -
246
add {base::operator-=} \
247
    {base (base * const, const base &)} \
248
    - \
249
    -
250
add {base::operator*} \
251
    {int (const base * const, const base &)} \
252
    - \
253
    -
254
add {base::operator*=} \
255
    {base (base * const, const base &)} \
256
    - \
257
    -
258
add {base::operator/} \
259
    {int (const base * const, const base &)} \
260
    - \
261
    -
262
add {base::operator/=} \
263
    {base (base * const, const base &)} \
264
    - \
265
    -
266
add {base::operator%} \
267
    {int (const base * const, const base &)} \
268
    - \
269
    -
270
add {base::operator%=} \
271
    {base (base * const, const base &)} \
272
    - \
273
    -
274
add {base::operator<} \
275
    {bool (const base * const, const base &)} \
276
    - \
277
    -
278
add {base::operator<=} \
279
    {bool (const base * const, const base &)} \
280
    - \
281
    -
282
add {base::operator>} \
283
    {bool (const base * const, const base &)} \
284
    - \
285
    -
286
add {base::operator>=} \
287
    {bool (const base * const, const base &)} \
288
    - \
289
    -
290
add {base::operator!=} \
291
    {bool (const base * const, const base &)} \
292
    - \
293
    -
294
add {base::operator==} \
295
    {bool (const base * const, const base &)} \
296
    - \
297
    -
298
add {base::operator!} \
299
    {bool (const base * const)} \
300
    - \
301
    -
302
add {base::operator&&} \
303
    {bool (const base * const, const base &)} \
304
    - \
305
    -
306
add {base::operator||} \
307
    {bool (const base * const, const base &)} \
308
    - \
309
    -
310
add {base::operator<<} \
311
    {int (const base * const, int)} \
312
    - \
313
    -
314
add {base::operator<<=} \
315
    {base (base * const, int)} \
316
    - \
317
    -
318
add {base::operator>>} \
319
    {int (const base * const, int)} \
320
    - \
321
    -
322
add {base::operator>>=} \
323
    {base (base * const, int)} \
324
    - \
325
    -
326
add {base::operator~} \
327
    {int (const base * const)} \
328
    - \
329
    -
330
add {base::operator&} \
331
    {int (const base * const, const base &)} \
332
    - \
333
    -
334
add {base::operator&=} \
335
    {base (base * const, const base &)} \
336
    - \
337
    -
338
add {base::operator|} \
339
    {int (const base * const, const base &)} \
340
    - \
341
    -
342
add {base::operator|=} \
343
    {base (base * const, const base &)} \
344
    - \
345
    -
346
add {base::operator^} \
347
    {int (const base * const, const base &)} \
348
    - \
349
    -
350
add {base::operator^=} \
351
    {base (base * const, const base &)} \
352
    - \
353
    -
354
add {base::operator=} \
355
    {base (base * const, const base &)} \
356
    - \
357
    -
358
add {base::operator()} \
359
    {void (const base * const)} \
360
    - \
361
    -
362
add {base::operator[]} \
363
    {int (const base * const, int)} \
364
    - \
365
    -
366
add {base::operator new} \
367
    {void *(size_t)} \
368
    - \
369
    -
370
add {base::operator delete} \
371
    {void (void *)} \
372
    - \
373
    -
374
add {base::operator new[]} \
375
    {void *(size_t)} \
376
    - \
377
    -
378
add {base::operator delete[]} \
379
    {void (void *)} \
380
    - \
381
    -
382
add {base::operator char*} \
383
    {char *(const base * const)} \
384
    - \
385
    -
386
add {base::operator fluff*} \
387
    {fluff *(const base * const)} \
388
    - \
389
    -
390
add {base::operator fluff**} \
391
    {fluff **(const base * const)} \
392
    - \
393
    -
394
add {base::operator int} \
395
    {int (const base * const)} \
396
    - \
397
    -
398
 
399
# Templates
400
add {tclass::do_something} \
401
    {void (tclass * const)} \
402
    - \
403
    -
404
add {tclass::do_something} \
405
    {void (tclass * const)} \
406
    - \
407
    -
408
add {tclass::do_something} \
409
    {void (tclass * const)} \
410
    - \
411
    -
412
add {tclass::do_something} \
413
    {void (tclass * const)} \
414
    - \
415
    -
416
add {tclass::do_something} \
417
    {void (tclass * const)} \
418
    - \
419
    -
420
add {flubber} \
421
    {void (void)} \
422
    - \
423
    flubber
424
add {flubber} \
425
    {void (void)} \
426
    - \
427
    flubber
428
add {flubber} \
429
    {void (void)} \
430
    - \
431
    flubber
432
add {flubber} \
433
    {void (void)} \
434
    - \
435
    flubber
436
add {flubber} \
437
    {void (void)} \
438
    - \
439
    flubber
440
add {flubber} \
441
    {void (void)} \
442
    - \
443
    flubber
444
add {flubber} \
445
    {void (void)} \
446
    - \
447
    flubber
448
add {flubber} \
449
    {void (void)} \
450
    - \
451
    flubber
452
add {flubber} \
453
    {void (void)} \
454
    - \
455
    flubber
456
add {flubber} \
457
    {void (void)} \
458
    - \
459
    flubber
460
add {flubber} \
461
    {void (void)} \
462
    - \
463
    flubber
464
add {flubber} \
465
    {void (void)} \
466
    - \
467
    flubber
468
add {flubber} \
469
    {void (void)} \
470
    - \
471
    flubber
472
add {flubber} \
473
    {void (void)} \
474
    - \
475
    flubber
476
add {flubber} \
477
    {void (void)} \
478
    - \
479
    flubber
480
add {flubber} \
481
    {void (void)} \
482
    - \
483
    flubber
484
add {flubber} \
485
    {void (void)} \
486
    - \
487
    flubber
488
add {flubber} \
489
    {void (void)} \
490
    - \
491
    flubber
492
add {flubber} \
493
    {void (void)} \
494
    - \
495
    flubber
496
add {flubber} \
497
    {void (void)} \
498
    - \
499
    flubber
500
add {flubber} \
501
    {void (void)} \
502
    - \
503
    flubber
504
add {flubber} \
505
    {void (void)} \
506
    - \
507
    flubber
508
add {flubber} \
509
    {void (void)} \
510
    - \
511
    flubber
512
add {tclass::do_something} \
513
    {void (tclass * const)} \
514
    - \
515
    {tclass::do_something}
516
add {policy1::policy} \
517
    [ctor "policy >" "int"] \
518
    {policy >::policy} \
519
    {policy::policy}
520
add {policy2::policy} \
521
    [ctor "policy >" int] \
522
    {policy >::policy} \
523
    {policy::policy}
524
add {policy3::policy} \
525
    [ctor "policy >" "int"] \
526
    {policy >::policy} \
527
    {policy::policy}
528
add {policy4::policy} \
529
    [ctor "policy >" "int"] \
530
    {policy >::policy} \
531
    {policy::policy}
532
add {policy1::function} \
533
    {void (void)} \
534
    {operation_1::function} \
535
    {operation_1::function}
536
add {policy2::function} \
537
    {void (void)} \
538
    {operation_2::function} \
539
    {operation_2::function}
540
add {policy3::function} \
541
    {void (void)} \
542
    {operation_3::function} \
543
    {operation_3::function}
544
add {policy4::function} \
545
    {void (void)} \
546
    {operation_4::function} \
547
    {operation_4::function}
548
add {policyd >::policyd} \
549
    [ctor "policyd >" "int"] \
550
    - \
551
    {policyd::policyd}
552
add {policyd1::policyd} \
553
    [ctor "policyd >" "int"] \
554
    {policyd >::policyd} \
555
    {policyd::policyd}
556
add {policyd >::~policyd} \
557
    [dtor "policyd >"] \
558
    - \
559
    {policyd::~policyd}
560
add {policyd1::~policyd} \
561
    [dtor "policyd >"] \
562
    {policyd >::~policyd} \
563
    {policyd::~policyd}
564
add {policyd >::policyd} \
565
    [ctor "policyd >" "long"] \
566
    - \
567
    {policyd::policyd}
568
add {policyd2::policyd} \
569
    [ctor "policyd >" "long"] \
570
    {policyd >::policyd} \
571
    {policyd::policyd}
572
add {policyd >::~policyd} \
573
    [dtor "policyd >"] \
574
    - \
575
    {policyd::~policyd}
576
add {policyd2::~policyd} \
577
    [dtor "policyd >"] \
578
    {policyd >::~policyd} \
579
    {policyd::~policyd}
580
add {policyd >::policyd} \
581
    [ctor "policyd >" "char"] \
582
    - \
583
    {policyd::policyd}
584
add {policyd3::policyd} \
585
    [ctor "policyd >" "char"] \
586
    {policyd >::policyd} \
587
    {policyd::policyd}
588
add {policyd >::~policyd} \
589
    [dtor "policyd >"] \
590
    - \
591
    {policyd::~policyd}
592
add {policyd3::~policyd} \
593
    [dtor "policyd >"] \
594
    {policyd >::~policyd} \
595
    {policyd::~policyd}
596
add {policyd >::policyd} \
597
    [ctor "policyd >" "base"] \
598
    - \
599
    {policyd::policyd}
600
add {policyd4::policyd} \
601
    [ctor "policyd >" "base"] \
602
    {policyd >::policyd} \
603
    {policyd::policyd}
604
add {policyd >::~policyd} \
605
    [dtor "policyd >"] \
606
    - \
607
    {policyd::~policyd}
608
add {policyd4::~policyd} \
609
    [dtor "policyd >"] \
610
    {policyd >::~policyd} \
611
    {policyd::~policyd}
612
add {policyd, operation_1 > >::policyd} \
613
    [ctor "policyd, operation_1 > >" "tclass"] \
614
    - \
615
    {policyd::policyd}
616
add {policyd5::policyd} \
617
    [ctor "policyd, operation_1 > >" "tclass"] \
618
    {policyd, operation_1 > >::policyd} \
619
    {policyd::policyd}
620
add {policyd, operation_1 > >::~policyd} \
621
    [dtor "policyd, operation_1 > >"] \
622
    - \
623
    {policyd::~policyd}
624
add {policyd5::~policyd} \
625
    [dtor "policyd, operation_1 > >"] \
626
    {policyd, operation_1 > >::~policyd} \
627
    {policyd::~policyd}
628
add {policyd >::function} \
629
    {void (void)} \
630
    {operation_1::function}\
631
    {operation_1::function}
632
add {policyd1::function} \
633
    {void (void)} \
634
    {operation_1::function} \
635
    {operation_1::function}
636
add {policyd2::function} \
637
    {void (void)} \
638
    {operation_1::function} \
639
    {operation_1::function}
640
add {policyd >::function} \
641
    {void (void)} \
642
    {operation_1::function} \
643
    {operation_1::function}
644
add {policyd3::function} \
645
    {void (void)} \
646
    {operation_1::function} \
647
    {operation_1::function}
648
add {policyd >::function} \
649
    {void (void)} \
650
    {operation_1::function} \
651
    {operation_1::function}
652
add {policyd4::function} \
653
    {void (void)} \
654
    {operation_1::function} \
655
    {operation_1::function}
656
add {policyd, operation_1 > >::function} \
657
    {void (void)} \
658
    {operation_1 >::function} \
659
    {operation_1::function}
660
add {policyd5::function} \
661
    {void (void)} \
662
    {operation_1 >::function} \
663
    {operation_1::function}
664
 
665
# Start the test
666
if {$tracelevel} {
667
    strace $tracelevel
668
}
669
 
670
if {[skip_cplus_tests]} { continue }
671
 
672
# On SPU this test fails because the executable exceeds local storage size.
673
if { [istarget "spu*-*-*"] } {
674
        return 0
675
}
676
 
677
#
678
# test running programs
679
#
680
 
681
set testfile "cpexprs"
682
set srcfile "${testfile}.cc"
683
set binfile [file join $objdir $subdir $testfile]
684
 
685
if  {[gdb_compile [file join $srcdir $subdir $srcfile] $binfile \
686
          executable {debug c++}] != "" } {
687
    untested "$testfile.exp"
688
    return -1
689
}
690
 
691
if {[get_compiler_info $binfile "c++"]} {
692
    return -1
693
}
694
 
695
gdb_exit
696
gdb_start
697
gdb_reinitialize_dir [file join $srcdir $subdir]
698
gdb_load $binfile
699
 
700
if {![runto_main]} {
701
    perror "couldn't run to breakpoint"
702
    continue
703
}
704
 
705
# Set the listsize to one. This will help with testing "list".
706
gdb_test "set listsize 1"
707
 
708
# "print METHOD"
709
foreach name [get_functions print] {
710
    gdb_test "print $name" [get $name print] "print $name"
711
}
712
 
713
# "list METHOD"
714
foreach name [get_functions list] {
715
    gdb_test "list $name" [get $name list] "list $name"
716
}
717
 
718
# Running to breakpoint -- use any function we can "list"
719
foreach name [get_functions list] {
720
    # Skip "main", since test_breakpoint uses it
721
    if {[string compare $name "main"] != 0} {
722
        test_breakpoint $name
723
    }
724
}
725
 
726
gdb_exit
727
return 0

powered by: WebSVN 2.1.0

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