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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-stable/] [gcc-4.5.1/] [gcc/] [testsuite/] [lib/] [gcc-dg.exp] - Blame information for rev 859

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

Line No. Rev Author Line
1 306 jeremybenn
#   Copyright (C) 1997, 1999, 2000, 2003, 2004, 2005, 2006, 2007, 2008, 2009
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 3 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 GCC; see the file COPYING3.  If not see
16
# .
17
 
18
load_lib dg.exp
19
load_lib file-format.exp
20
load_lib target-supports.exp
21
load_lib target-supports-dg.exp
22
load_lib scanasm.exp
23
load_lib scanrtl.exp
24
load_lib scantree.exp
25
load_lib scanipa.exp
26
load_lib timeout.exp
27
load_lib timeout-dg.exp
28
load_lib prune.exp
29
load_lib libgloss.exp
30
load_lib target-libpath.exp
31
load_lib torture-options.exp
32
 
33
# We set LC_ALL and LANG to C so that we get the same error messages as expected.
34
setenv LC_ALL C
35
setenv LANG C
36
 
37
# Many hosts now default to a non-ASCII C locale, however, so
38
# they can set a charset encoding here if they need.
39
if { [ishost "*-*-cygwin*"] } {
40
  setenv LC_ALL C.ASCII
41
  setenv LANG C.ASCII
42
}
43
 
44
if [info exists TORTURE_OPTIONS] {
45
    set DG_TORTURE_OPTIONS $TORTURE_OPTIONS
46
} else {
47
    # It is theoretically beneficial to group all of the O2/O3 options together,
48
    # as in many cases the compiler will generate identical executables for
49
    # all of them--and the c-torture testsuite will skip testing identical
50
    # executables multiple times.
51
    # Also note that -finline-functions is explicitly included in one of the
52
    # items below, even though -O3 is also specified, because some ports may
53
    # choose to disable inlining functions by default, even when optimizing.
54
    set DG_TORTURE_OPTIONS [list \
55
        { -O0 } \
56
        { -O1 } \
57
        { -O2 } \
58
        { -O3 -fomit-frame-pointer } \
59
        { -O3 -fomit-frame-pointer -funroll-loops } \
60
        { -O3 -fomit-frame-pointer -funroll-all-loops -finline-functions } \
61
        { -O3 -g } \
62
        { -Os } ]
63
}
64
 
65
if [info exists ADDITIONAL_TORTURE_OPTIONS] {
66
    set DG_TORTURE_OPTIONS \
67
        [concat $DG_TORTURE_OPTIONS $ADDITIONAL_TORTURE_OPTIONS]
68
}
69
 
70
set LTO_TORTURE_OPTIONS ""
71
if [check_effective_target_lto] {
72
    set LTO_TORTURE_OPTIONS [list \
73
        { -O2 -flto } \
74
        { -O2 -fwhopr }
75
    ]
76
}
77
 
78
 
79
global GCC_UNDER_TEST
80
if ![info exists GCC_UNDER_TEST] {
81
    set GCC_UNDER_TEST "[find_gcc]"
82
}
83
 
84
global orig_environment_saved
85
 
86
# This file may be sourced, so don't override environment settings
87
# that have been previously setup.
88
if { $orig_environment_saved == 0 } {
89
    append ld_library_path [gcc-set-multilib-library-path $GCC_UNDER_TEST]
90
    set_ld_library_path_env_vars
91
}
92
 
93
# Define gcc callbacks for dg.exp.
94
 
95
proc gcc-dg-test-1 { target_compile prog do_what extra_tool_flags } {
96
    # Set up the compiler flags, based on what we're going to do.
97
 
98
    set options [list]
99
 
100
    # Tests should be able to use "dg-do repo".  However, the dg test
101
    # driver checks the argument to dg-do against a list of acceptable
102
    # options, and "repo" is not among them.  Therefore, we resort to
103
    # this ugly approach.
104
    if [string match "*-frepo*" $extra_tool_flags] then {
105
        set do_what "repo"
106
    }
107
 
108
    switch $do_what {
109
        "preprocess" {
110
            set compile_type "preprocess"
111
            set output_file "[file rootname [file tail $prog]].i"
112
        }
113
        "compile" {
114
            set compile_type "assembly"
115
            set output_file "[file rootname [file tail $prog]].s"
116
        }
117
        "assemble" {
118
            set compile_type "object"
119
            set output_file "[file rootname [file tail $prog]].o"
120
        }
121
        "precompile" {
122
            set compile_type "precompiled_header"
123
            set output_file "[file tail $prog].gch"
124
        }
125
        "link" {
126
            set compile_type "executable"
127
            set output_file "[file rootname [file tail $prog]].exe"
128
            # The following line is needed for targets like the i960 where
129
            # the default output file is b.out.  Sigh.
130
        }
131
        "repo" {
132
            set compile_type "object"
133
            set output_file "[file rootname [file tail $prog]].o"
134
        }
135
        "run" {
136
            set compile_type "executable"
137
            # FIXME: "./" is to cope with "." not being in $PATH.
138
            # Should this be handled elsewhere?
139
            # YES.
140
            set output_file "./[file rootname [file tail $prog]].exe"
141
            # This is the only place where we care if an executable was
142
            # created or not.  If it was, dg.exp will try to run it.
143
            catch { remote_file build delete $output_file }
144
        }
145
        default {
146
            perror "$do_what: not a valid dg-do keyword"
147
            return ""
148
        }
149
    }
150
 
151
    if { $extra_tool_flags != "" } {
152
        lappend options "additional_flags=$extra_tool_flags"
153
    }
154
 
155
    set comp_output [$target_compile "$prog" "$output_file" "$compile_type" $options]
156
 
157
    # Look for an internal compiler error, which sometimes masks the fact
158
    # that we didn't get an expected error message.  XFAIL an ICE via
159
    # dg-xfail-if and use { dg-prune-output ".*internal compiler error.*" }
160
    # to avoid a second failure for excess errors.
161
    if [string match "*internal compiler error*" $comp_output] {
162
        upvar 2 name name
163
        fail "$name (internal compiler error)"
164
    }
165
 
166
    if { $do_what == "repo" } {
167
        set object_file "$output_file"
168
        set output_file "[file rootname [file tail $prog]].exe"
169
        set comp_output \
170
            [ concat $comp_output \
171
                  [$target_compile "$object_file" "$output_file" \
172
                       "executable" $options] ]
173
    }
174
 
175
    return [list $comp_output $output_file]
176
}
177
 
178
proc gcc-dg-test { prog do_what extra_tool_flags } {
179
    return [gcc-dg-test-1 gcc_target_compile $prog $do_what $extra_tool_flags]
180
}
181
 
182
proc gcc-dg-prune { system text } {
183
    global additional_prunes
184
 
185
    set text [prune_gcc_output $text]
186
 
187
    foreach p $additional_prunes {
188
        if { [string length $p] > 0 } {
189
            # Following regexp matches a complete line containing $p.
190
            regsub -all "(^|\n)\[^\n\]*$p\[^\n\]*" $text "" text
191
        }
192
    }
193
 
194
    # If we see "region xxx is full" then the testcase is too big for ram.
195
    # This is tricky to deal with in a large testsuite like c-torture so
196
    # deal with it here.  Just mark the testcase as unsupported.
197
    if [regexp "(^|\n)\[^\n\]*: region \[^\n\]* is full" $text] {
198
        # The format here is important.  See dg.exp.
199
        return "::unsupported::memory full"
200
    }
201
 
202
    # Likewise, if we see ".text exceeds local store range" or
203
    # similar.
204
    if {[string match "spu-*" $system] && \
205
            [string match "*exceeds local store*" $text]} {
206
        # The format here is important.  See dg.exp.
207
        return "::unsupported::memory full"
208
    }
209
 
210
    return $text
211
}
212
 
213
# Replace ${tool}_load with a wrapper to provide for an expected nonzero
214
# exit status.  Multiple languages include this file so this handles them
215
# all, not just gcc.
216
if { [info procs ${tool}_load] != [list] \
217
      && [info procs saved_${tool}_load] == [list] } {
218
    rename ${tool}_load saved_${tool}_load
219
 
220
    proc ${tool}_load { program args } {
221
        global tool
222
        global shouldfail
223
        set result [eval [list saved_${tool}_load $program] $args]
224
        if { $shouldfail != 0 } {
225
            switch [lindex $result 0] {
226
                "pass" { set status "fail" }
227
                "fail" { set status "pass" }
228
            }
229
            set result [list $status [lindex $result 1]]
230
        }
231
        return $result
232
    }
233
}
234
 
235
# Utility routines.
236
 
237
#
238
# search_for -- looks for a string match in a file
239
#
240
proc search_for { file pattern } {
241
    set fd [open $file r]
242
    while { [gets $fd cur_line]>=0 } {
243
        if [string match "*$pattern*" $cur_line] then {
244
            close $fd
245
            return 1
246
        }
247
    }
248
    close $fd
249
    return 0
250
}
251
 
252
# Modified dg-runtest that can cycle through a list of optimization options
253
# as c-torture does.
254
proc gcc-dg-runtest { testcases default-extra-flags } {
255
    global runtests
256
 
257
    # Some callers set torture options themselves; don't override those.
258
    set existing_torture_options [torture-options-exist]
259
    if { $existing_torture_options == 0 } {
260
        global DG_TORTURE_OPTIONS LTO_TORTURE_OPTIONS
261
        torture-init
262
        set-torture-options $DG_TORTURE_OPTIONS [list {}] $LTO_TORTURE_OPTIONS
263
    }
264
    dump-torture-options
265
 
266
    foreach test $testcases {
267
        global torture_with_loops torture_without_loops
268
        # If we're only testing specific files and this isn't one of
269
        # them, skip it.
270
        if ![runtest_file_p $runtests $test] {
271
            continue
272
        }
273
 
274
        # Look for a loop within the source code - if we don't find one,
275
        # don't pass -funroll[-all]-loops.
276
        if [expr [search_for $test "for*("]+[search_for $test "while*("]] {
277
            set option_list $torture_with_loops
278
        } else {
279
            set option_list $torture_without_loops
280
        }
281
 
282
        set nshort [file tail [file dirname $test]]/[file tail $test]
283
 
284
        foreach flags $option_list {
285
            verbose "Testing $nshort, $flags" 1
286
            dg-test $test $flags ${default-extra-flags}
287
        }
288
    }
289
 
290
    if { $existing_torture_options == 0 } {
291
        torture-finish
292
    }
293
}
294
 
295
proc gcc-dg-debug-runtest { target_compile trivial opt_opts testcases } {
296
    global srcdir subdir
297
 
298
    if ![info exists DEBUG_TORTURE_OPTIONS] {
299
        set DEBUG_TORTURE_OPTIONS ""
300
        foreach type {-gdwarf-2 -gstabs -gstabs+ -gxcoff -gxcoff+ -gcoff} {
301
            set comp_output [$target_compile \
302
                    "$srcdir/$subdir/$trivial" "trivial.S" assembly \
303
                    "additional_flags=$type"]
304
            if { ! [string match "*: target system does not support the * debug format*" \
305
                    $comp_output] } {
306
                remove-build-file "trivial.S"
307
                foreach level {1 "" 3} {
308
                    if { ($type == "-gdwarf-2") && ($level != "") } {
309
                        lappend DEBUG_TORTURE_OPTIONS [list "${type}" "-g${level}"]
310
                        foreach opt $opt_opts {
311
                            lappend DEBUG_TORTURE_OPTIONS \
312
                                    [list "${type}" "-g${level}" "$opt" ]
313
                        }
314
                    } else {
315
                        lappend DEBUG_TORTURE_OPTIONS [list "${type}${level}"]
316
                        foreach opt $opt_opts {
317
                            lappend DEBUG_TORTURE_OPTIONS \
318
                                    [list "${type}${level}" "$opt" ]
319
                        }
320
                    }
321
                }
322
            }
323
        }
324
    }
325
 
326
    verbose -log "Using options $DEBUG_TORTURE_OPTIONS"
327
 
328
    global runtests
329
 
330
    foreach test $testcases {
331
        # If we're only testing specific files and this isn't one of
332
        # them, skip it.
333
        if ![runtest_file_p $runtests $test] {
334
            continue
335
        }
336
 
337
        set nshort [file tail [file dirname $test]]/[file tail $test]
338
 
339
        foreach flags $DEBUG_TORTURE_OPTIONS {
340
            set doit 1
341
 
342
            # These tests check for information which may be deliberately
343
            # suppressed at -g1.
344
            if { ([string match {*/debug-[126].c} "$nshort"] \
345
                   || [string match {*/enum-1.c} "$nshort"] \
346
                   || [string match {*/enum-[12].C} "$nshort"]) \
347
                    && ([string match "*1" [lindex "$flags" 0] ]
348
                        || [lindex "$flags" 1] == "-g1") } {
349
                set doit 0
350
            }
351
 
352
    # High optimization can remove the variable whose existence is tested.
353
    # Dwarf debugging with commentary (-dA) preserves the symbol name in the
354
    # assembler output, but stabs debugging does not.
355
    # http://gcc.gnu.org/ml/gcc-regression/2003-04/msg00095.html
356
            if { [string match {*/debug-[12].c} "$nshort"] \
357
                    && [string match "*O*" "$flags"] \
358
                    && ( [string match "*coff*" "$flags"] \
359
                         || [string match "*stabs*" "$flags"] ) } {
360
                set doit 0
361
            }
362
 
363
            if { $doit } {
364
                verbose -log "Testing $nshort, $flags" 1
365
                dg-test $test $flags ""
366
            }
367
        }
368
    }
369
}
370
 
371
# Prune any messages matching ARGS[1] (a regexp) from test output.
372
proc dg-prune-output { args } {
373
    global additional_prunes
374
 
375
    if { [llength $args] != 2 } {
376
        error "[lindex $args 1]: need one argument"
377
        return
378
    }
379
 
380
    lappend additional_prunes [lindex $args 1]
381
}
382
 
383
# Remove files matching the pattern from the build machine.
384
proc remove-build-file { pat } {
385
    verbose "remove-build-file `$pat'" 2
386
    set file_list "[glob -nocomplain $pat]"
387
    verbose "remove-build-file `$file_list'" 2
388
    foreach output_file $file_list {
389
        if [is_remote host] {
390
            # Ensure the host knows the file is gone by deleting there
391
            # first.
392
            remote_file host delete $output_file
393
        }
394
        remote_file build delete $output_file
395
    }
396
}
397
 
398
# Remove runtime-generated profile file for the current test.
399
proc cleanup-profile-file { } {
400
    remove-build-file "mon.out"
401
    remove-build-file "gmon.out"
402
}
403
 
404
# Remove compiler-generated coverage files for the current test.
405
proc cleanup-coverage-files { } {
406
    # This assumes that we are two frames down from dg-test or some other proc
407
    # that stores the filename of the testcase in a local variable "name".
408
    # A cleaner solution would require a new DejaGnu release.
409
    upvar 2 name testcase
410 378 julius
    # The name might include a list of options; extract the file name.
411
    set testcase [lindex $testcase 0]]
412 306 jeremybenn
    remove-build-file "[file rootname [file tail $testcase]].gc??"
413
 
414
    # Clean up coverage files for additional source files.
415
    if [info exists additional_sources] {
416
        foreach srcfile $additional_sources {
417
            remove-build-file "[file rootname [file tail $srcfile]].gc??"
418
        }
419
    }
420
}
421
 
422
# Remove compiler-generated files from -repo for the current test.
423
proc cleanup-repo-files { } {
424
    # This assumes that we are two frames down from dg-test or some other proc
425
    # that stores the filename of the testcase in a local variable "name".
426
    # A cleaner solution would require a new DejaGnu release.
427
    upvar 2 name testcase
428 378 julius
    # The name might include a list of options; extract the file name.
429
    set testcase [lindex $testcase 0]]
430 306 jeremybenn
    remove-build-file "[file rootname [file tail $testcase]].o"
431
    remove-build-file "[file rootname [file tail $testcase]].rpo"
432
 
433
    # Clean up files for additional source files.
434
    if [info exists additional_sources] {
435
        foreach srcfile $additional_sources {
436
            remove-build-file "[file rootname [file tail $srcfile]].o"
437
            remove-build-file "[file rootname [file tail $srcfile]].rpo"
438
        }
439
    }
440
}
441
 
442
# Remove compiler-generated RTL dump files for the current test.
443
#
444
# SUFFIX is the filename suffix pattern.
445
proc cleanup-rtl-dump { suffix } {
446
  cleanup-dump "\[0-9\]\[0-9\]\[0-9\]r.$suffix"
447
}
448
 
449
# Remove a specific tree dump file for the current test.
450
#
451
# SUFFIX is the tree dump file suffix pattern.
452
proc cleanup-tree-dump { suffix } {
453
  cleanup-dump "\[0-9\]\[0-9\]\[0-9\]t.$suffix"
454
}
455
 
456
# Remove a specific ipa dump file for the current test.
457
#
458
# SUFFIX is the ipa dump file suffix pattern.
459
proc cleanup-ipa-dump { suffix } {
460
  cleanup-dump "\[0-9\]\[0-9\]\[0-9\]i.$suffix"
461
}
462
 
463
# Remove all dump files with the provided suffix.
464
proc cleanup-dump { suffix } {
465
    # This assumes that we are three frames down from dg-test or some other
466
    # proc that stores the filename of the testcase in a local variable
467
    # "name".  A cleaner solution would require a new DejaGnu release.
468
    upvar 3 name testcase
469
    # The name might include a list of options; extract the file name.
470
    set src [file tail [lindex $testcase 0]]
471
    remove-build-file "[file tail $src].$suffix"
472
    # -fcompare-debug dumps
473
    remove-build-file "[file tail $src].gk.$suffix"
474
 
475
    # Clean up dump files for additional source files.
476
    if [info exists additional_sources] {
477
        foreach srcfile $additional_sources {
478
            remove-build-file "[file tail $srcfile].$suffix"
479
            # -fcompare-debug dumps
480
            remove-build-file "[file tail $srcfile].gk.$suffix"
481
        }
482
    }
483
}
484
 
485
# Remove files kept by --save-temps for the current test.
486
#
487
# Currently this is only .i, .ii, .s and .o files, but more can be added
488
# if there are tests generating them.
489
# ARGS is a list of suffixes to NOT delete.
490
proc cleanup-saved-temps { args } {
491
    global additional_sources
492
    set suffixes {}
493
 
494
    # add the to-be-kept suffixes
495
    foreach suffix {".ii" ".i" ".s" ".o" ".gkd"} {
496
        if {[lsearch $args $suffix] < 0} {
497
            lappend suffixes $suffix
498
        }
499
    }
500
 
501
    # This assumes that we are two frames down from dg-test or some other proc
502
    # that stores the filename of the testcase in a local variable "name".
503
    # A cleaner solution would require a new DejaGnu release.
504
    upvar 2 name testcase
505 378 julius
    # The name might include a list of options; extract the file name.
506
    set testcase [lindex $testcase 0]]
507 306 jeremybenn
    foreach suffix $suffixes {
508
        remove-build-file "[file rootname [file tail $testcase]]$suffix"
509
        # -fcompare-debug dumps
510
        remove-build-file "[file rootname [file tail $testcase]].gk$suffix"
511
    }
512
 
513
    # Clean up saved temp files for additional source files.
514
    if [info exists additional_sources] {
515
        foreach srcfile $additional_sources {
516
            foreach suffix $suffixes {
517
                remove-build-file "[file rootname [file tail $srcfile]]$suffix"
518
                # -fcompare-debug dumps
519
                remove-build-file "[file rootname [file tail $srcfile]].gk$suffix"
520
            }
521
        }
522
    }
523
}
524
 
525
# Remove files for specified Fortran modules.
526
proc cleanup-modules { modlist } {
527
    foreach modname $modlist {
528
        remove-build-file [string tolower $modname].mod
529
    }
530
}
531
 
532
# Scan Fortran modules for a given regexp.
533
#
534
# Argument 0 is the module name
535
# Argument 1 is the regexp to match
536
proc scan-module { args } {
537
    set modfilename [string tolower [lindex $args 0]].mod
538
    set fd [open $modfilename r]
539
    set text [read $fd]
540
    close $fd
541
 
542
    upvar 2 name testcase
543
    if [regexp -- [lindex $args 1] $text] {
544
      pass "$testcase scan-module [lindex $args 1]"
545
    } else {
546
      fail "$testcase scan-module [lindex $args 1]"
547
    }
548
}
549
 
550
# Verify that the compiler output file exists, invoked via dg-final.
551
proc output-exists { args } {
552
    # Process an optional target or xfail list.
553
    if { [llength $args] >= 1 } {
554
        switch [dg-process-target [lindex $args 0]] {
555
            "S" { }
556
            "N" { return }
557
            "F" { setup_xfail "*-*-*" }
558
            "P" { }
559
        }
560
    }
561
 
562
    # Access variables from gcc-dg-test-1.
563
    upvar 2 name testcase
564
    upvar 2 output_file output_file
565
 
566
    if [file exists $output_file] {
567
        pass "$testcase output-exists $output_file"
568
    } else {
569
        fail "$testcase output-exists $output_file"
570
    }
571
}
572
 
573
# Verify that the compiler output file does not exist, invoked via dg-final.
574
proc output-exists-not { args } {
575
    # Process an optional target or xfail list.
576
    if { [llength $args] >= 1 } {
577
        switch [dg-process-target [lindex $args 0]] {
578
            "S" { }
579
            "N" { return }
580
            "F" { setup_xfail "*-*-*" }
581
            "P" { }
582
        }
583
    }
584
 
585
    # Access variables from gcc-dg-test-1.
586
    upvar 2 name testcase
587
    upvar 2 output_file output_file
588
 
589
    if [file exists $output_file] {
590
        fail "$testcase output-exists-not $output_file"
591
    } else {
592
        pass "$testcase output-exists-not $output_file"
593
    }
594
}
595
 
596
# We need to make sure that additional_* are cleared out after every
597
# test.  It is not enough to clear them out *before* the next test run
598
# because gcc-target-compile gets run directly from some .exp files
599
# (outside of any test).  (Those uses should eventually be eliminated.)
600
 
601
# Because the DG framework doesn't provide a hook that is run at the
602
# end of a test, we must replace dg-test with a wrapper.
603
 
604
if { [info procs saved-dg-test] == [list] } {
605
    rename dg-test saved-dg-test
606
 
607
    proc dg-test { args } {
608
        global additional_files
609
        global additional_sources
610
        global additional_prunes
611
        global errorInfo
612
        global compiler_conditional_xfail_data
613
        global shouldfail
614
 
615
        if { [ catch { eval saved-dg-test $args } errmsg ] } {
616
            set saved_info $errorInfo
617
            set additional_files ""
618
            set additional_sources ""
619
            set additional_prunes ""
620
            set shouldfail 0
621
            if [info exists compiler_conditional_xfail_data] {
622
                unset compiler_conditional_xfail_data
623
            }
624
            unset_timeout_vars
625
            error $errmsg $saved_info
626
        }
627
        set additional_files ""
628
        set additional_sources ""
629
        set additional_prunes ""
630
        set shouldfail 0
631
        unset_timeout_vars
632
        if [info exists compiler_conditional_xfail_data] {
633
            unset compiler_conditional_xfail_data
634
        }
635
    }
636
}
637
 
638
if { [info procs saved-dg-warning] == [list] \
639
     && [info exists gcc_warning_prefix] } {
640
    rename dg-warning saved-dg-warning
641
 
642
    proc dg-warning { args } {
643
        # Make this variable available here and to the saved proc.
644
        upvar dg-messages dg-messages
645
        global gcc_warning_prefix
646
 
647
        process-message saved-dg-warning "$gcc_warning_prefix" "$args"
648
    }
649
}
650
 
651
if { [info procs saved-dg-error] == [list] \
652
     && [info exists gcc_error_prefix] } {
653
    rename dg-error saved-dg-error
654
 
655
    proc dg-error { args } {
656
        # Make this variable available here and to the saved proc.
657
        upvar dg-messages dg-messages
658
        global gcc_error_prefix
659
 
660
        process-message saved-dg-error "$gcc_error_prefix" "$args"
661
    }
662
 
663
    # Override dg-bogus at the same time.  It doesn't handle a prefix
664
    # but its expression should include a column number.  Otherwise the
665
    # line number can match the column number for other messages, leading
666
    # to insanity.
667
    rename dg-bogus saved-dg-bogus
668
 
669
    proc dg-bogus { args } {
670
        upvar dg-messages dg-messages
671
        process-message saved-dg-bogus "" $args
672
    }
673
}
674
 
675
# Modify the regular expression saved by a DejaGnu message directive to
676
# include a prefix and to force the expression to match a single line.
677
# MSGPROC is the procedure to call.
678
# MSGPREFIX is the prefix to prepend.
679
# DGARGS is the original argument list.
680
 
681
proc process-message { msgproc msgprefix dgargs } {
682
    upvar dg-messages dg-messages
683
 
684
    # Process the dg- directive, including adding the regular expression
685
    # to the new message entry in dg-messages.
686
    set msgcnt [llength ${dg-messages}]
687
    catch { eval $msgproc $dgargs }
688
 
689
    # If the target expression wasn't satisfied there is no new message.
690
    if { [llength ${dg-messages}] == $msgcnt } {
691
        return;
692
    }
693
 
694
    # Get the entry for the new message.  Prepend the message prefix to
695
    # the regular expression and make it match a single line.
696
    set newentry [lindex ${dg-messages} end]
697
    set expmsg [lindex $newentry 2]
698
 
699
    # Handle column numbers from the specified expression (if there is
700
    # one) and set up the search expression that will be used by DejaGnu.
701
    if [regexp "^(\[0-9\]+):" $expmsg "" column] {
702
        # The expression in the directive included a column number.
703
        # Remove "COLUMN:" from the original expression and move it
704
        # to the proper place in the search expression.
705
        regsub "^\[0-9\]+:" $expmsg "" expmsg
706
        set expmsg "$column: $msgprefix\[^\n\]*$expmsg"
707
    } elseif [string match "" [lindex $newentry 0]] {
708
        # The specified line number is 0; don't expect a column number.
709
        set expmsg "$msgprefix\[^\n\]*$expmsg"
710
    } else {
711
        # There is no column number in the search expression, but we
712
        # should expect one in the message itself.
713
        set expmsg "\[0-9\]+: $msgprefix\[^\n\]*$expmsg"
714
    }
715
 
716
    set newentry [lreplace $newentry 2 2 $expmsg]
717
    set dg-messages [lreplace ${dg-messages} end end $newentry]
718
    verbose "process-message:\n${dg-messages}" 2
719
}
720
 
721
# Look for messages that don't have standard prefixes.
722
 
723
proc dg-message { args } {
724
    upvar dg-messages dg-messages
725
    process-message saved-dg-warning "" $args
726
}
727
 
728
set additional_prunes ""

powered by: WebSVN 2.1.0

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