1 # Copyright
(C
) 2000, 2002, 2003, 2005 Free Software Foundation
, Inc.
3 # This
program is free software
; you can redistribute it and
/or modify
4 # it under the terms of the GNU General Public License as published by
5 # the Free Software Foundation
; either version
2 of the License
, or
6 #
(at your option
) any later version.
8 # This
program is distributed in the hope that it will be useful
,
9 # but WITHOUT
ANY WARRANTY
; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the
11 # GNU General Public License
for more details.
13 # You should have received a copy of the GNU General Public License
14 # along with this
program; if not
, write to the Free Software
15 # Foundation
, Inc.
, 51 Franklin Street
, Fifth Floor
, Boston
, MA
02110-1301, USA.
17 # Various utilities
for scanning dump output
, used by gcc
-dg.exp and
20 # This is largely borrowed from scanasm.exp.
22 # Utility
for scanning compiler result
, invoked via dg
-final.
23 #
Call pass
if pattern is present
, otherwise fail.
25 #
Argument 0 is the type of dump we are searching
(rtl
, tree
, ipa
)
26 #
Argument 1 is the regexp to match.
27 #
Argument 2 is the suffix
for the dump file
28 #
Argument 3 handles expected failures and the like
29 proc scan
-dump
{ args } {
31 if { [llength $
args] >= 4 } {
32 switch [dg
-process
-target
[lindex $
args 3]] {
35 "F" { setup_xfail "*-*-*" }
40 # This assumes that we are three frames down from dg
-test
, and that
41 # it still stores the filename of the testcase in a local
variable "name".
42 # A cleaner solution would require a new DejaGnu release.
45 set src
[file tail
[lindex $testcase
0]]
46 set output_file
"[glob $src.[lindex $args 2]]"
48 set fd
[open $output_file r
]
52 if [regexp
-- [lindex $
args 1] $
text] {
53 pass
"$testcase scan-[lindex $args 0]-dump [lindex $args 1]"
55 fail
"$testcase scan-[lindex $args 0]-dump [lindex $args 1]"
59 #
Call pass
if pattern is present given number of times
, otherwise fail.
60 #
Argument 0 is the type of dump we are searching
(rtl
, tree
, ipa
)
61 #
Argument 1 is the regexp to match.
62 #
Argument 2 is number of times the regexp must be found
63 #
Argument 3 is the suffix
for the dump file
64 #
Argument 4 handles expected failures and the like
65 proc scan
-dump
-times
{ args } {
67 if { [llength $
args] >= 5 } {
68 switch [dg
-process
-target
[lindex $
args 4]] {
71 "F" { setup_xfail "*-*-*" }
76 # This assumes that we are three frames down from dg
-test
, and that
77 # it still stores the filename of the testcase in a local
variable "name".
78 # A cleaner solution would require a new DejaGnu release.
81 set src
[file tail
[lindex $testcase
0]]
82 set output_file
"[glob $src.[lindex $args 3]]"
84 set fd
[open $output_file r
]
88 if { [llength
[regexp
-inline
-all
-- [lindex $
args 1] $
text]] == [lindex $
args 2]} {
89 pass
"$testcase scan-[lindex $args 0]-dump-times [lindex $args 1] [lindex $args 2]"
91 fail
"$testcase scan-[lindex $args 0]-dump-times [lindex $args 1] [lindex $args 2]"
95 #
Call pass
if pattern is not present
, otherwise fail.
97 #
Argument 0 is the type of dump we are searching
(rtl
, tree
, ipa
)
98 #
Argument 1 is the regexp to match.
99 #
Argument 2 is the suffix
for the dump file
100 #
Argument 3 handles expected failures and the like
101 proc scan
-dump
-not
{ args } {
103 if { [llength $
args] >= 4 } {
104 switch [dg
-process
-target
[lindex $
args 3]] {
107 "F" { setup_xfail "*-*-*" }
112 # This assumes that we are three frames down from dg
-test
, and that
113 # it still stores the filename of the testcase in a local
variable "name".
114 # A cleaner solution would require a new DejaGnu release.
115 upvar
3 name testcase
116 set src
[file tail
[lindex $testcase
0]]
117 set output_file
"[glob $src.[lindex $args 2]]"
119 set fd
[open $output_file r
]
123 if ![regexp
-- [lindex $
args 1] $
text] {
124 pass
"$testcase scan-[lindex $args 0]-dump-not [lindex $args 1]"
126 fail
"$testcase scan-[lindex $args 0]-dump-not [lindex $args 1]"
130 # Utility
for scanning demangled compiler result
, invoked via dg
-final.
131 #
Call pass
if pattern is present
, otherwise fail.
133 #
Argument 0 is the type of dump we are searching
(rtl
, tree
, ipa
)
134 #
Argument 1 is the regexp to match.
135 #
Argument 2 is the suffix
for the dump file
136 #
Argument 3 handles expected failures and the like
137 proc scan
-dump
-dem
{ args } {
141 if { [llength $
args] >= 4 } {
142 switch [dg
-process
-target
[lindex $
args 3]] {
145 "F" { setup_xfail "*-*-*" }
150 # Find c
++filt like we find g
++ in g
++.exp.
151 if ![info exists cxxfilt
] {
152 set cxxfilt
[findfile $base_dir
/..
/..
/..
/binutils
/cxxfilt \
153 $base_dir
/..
/..
/..
/binutils
/cxxfilt \
154 [findfile $base_dir
/..
/..
/c
++filt $base_dir
/..
/..
/c
++filt \
155 [findfile $base_dir
/c
++filt $base_dir
/c
++filt \
156 [transform c
++filt
]]]]
157 verbose
-log "c++filt is $cxxfilt"
160 upvar
3 name testcase
161 set src
[file tail
[lindex $testcase
0]]
162 set output_file
"[glob $src.[lindex $args 2]]"
164 set fd
[open
"| $cxxfilt < $output_file" r]
168 if [regexp
-- [lindex $
args 1] $
text] {
169 pass
"$testcase scan-[lindex $args 0]-dump-dem [lindex $args 1]"
171 fail
"$testcase scan-[lindex $args 0]-dump-dem [lindex $args 1]"
175 #
Call pass
if demangled pattern is not present
, otherwise fail.
177 #
Argument 0 is the type of dump we are searching
(rtl
, tree
, ipa
)
178 #
Argument 1 is the regexp to match.
179 #
Argument 2 is the suffix
for the dump file
180 #
Argument 3 handles expected failures and the like
181 proc scan
-dump
-dem
-not
{ args } {
185 if { [llength $
args] >= 4 } {
186 switch [dg
-process
-target
[lindex $
args 3]] {
189 "F" { setup_xfail "*-*-*" }
194 # Find c
++filt like we find g
++ in g
++.exp.
195 if ![info exists cxxfilt
] {
196 set cxxfilt
[findfile $base_dir
/..
/..
/..
/binutils
/cxxfilt \
197 $base_dir
/..
/..
/..
/binutils
/cxxfilt \
198 [findfile $base_dir
/..
/..
/c
++filt $base_dir
/..
/..
/c
++filt \
199 [findfile $base_dir
/c
++filt $base_dir
/c
++filt \
200 [transform c
++filt
]]]]
201 verbose
-log "c++filt is $cxxfilt"
204 upvar
3 name testcase
205 set src
[file tail
[lindex $testcase
0]]
206 set output_file
"[glob $src.[lindex $args 2]]"
208 set fd
[open
"| $cxxfilt < $output_file" r]
212 if ![regexp
-- [lindex $
args 1] $
text] {
213 pass
"$testcase scan-[lindex $args 0]-dump-dem-not [lindex $args 1]"
215 fail
"$testcase scan-[lindex $args 0]-dump-dem-not [lindex $args 1]"