1 # Copyright
(C
) 2000, 2002, 2003, 2005, 2007, 2008
2 # Free Software Foundation
, Inc.
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.
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.
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 #
<http
://www.gnu.org
/licenses
/>.
18 # Various utilities
for scanning dump output
, used by gcc
-dg.exp and
21 # This is largely borrowed from scanasm.exp.
23 # Extract the constant part of the dump file suffix from the regexp.
24 #
Argument 0 is the regular expression.
25 proc dump
-suffix
{ arg } {
26 set idx
[expr
[string last
"." $arg] + 1]
27 return [string range $
arg $idx end
]
30 # Utility
for scanning compiler result
, invoked via dg
-final.
31 #
Call pass
if pattern is present
, otherwise fail.
33 #
Argument 0 is the type of dump we are searching
(rtl
, tree
, ipa
)
34 #
Argument 1 is the regexp to match.
35 #
Argument 2 is the suffix
for the dump file
36 #
Argument 3 handles expected failures and the like
37 proc scan
-dump
{ args } {
39 if { [llength $
args] >= 4 } {
40 switch [dg
-process
-target
[lindex $
args 3]] {
43 "F" { setup_xfail "*-*-*" }
48 # This assumes that we are three frames down from dg
-test
, and that
49 # it still stores the filename of the testcase in a local
variable "name".
50 # A cleaner solution would require a new DejaGnu release.
53 set suf
[dump
-suffix
[lindex $
args 2]]
54 set testname
"$testcase scan-[lindex $args 0]-dump $suf \"[lindex $args 1]\""
55 set src
[file tail
[lindex $testcase
0]]
56 set output_file
"[glob -nocomplain $src.[lindex $args 2]]"
57 if { $output_file
== "" } {
58 verbose
-log "$testcase: dump file does not exist"
59 unresolved
"$testname"
63 set fd
[open $output_file r
]
67 if [regexp
-- [lindex $
args 1] $
text] {
74 #
Call pass
if pattern is present given number of times
, otherwise fail.
75 #
Argument 0 is the type of dump we are searching
(rtl
, tree
, ipa
)
76 #
Argument 1 is the regexp to match.
77 #
Argument 2 is number of times the regexp must be found
78 #
Argument 3 is the suffix
for the dump file
79 #
Argument 4 handles expected failures and the like
80 proc scan
-dump
-times
{ args } {
82 if { [llength $
args] >= 5 } {
83 switch [dg
-process
-target
[lindex $
args 4]] {
86 "F" { setup_xfail "*-*-*" }
91 # This assumes that we are three frames down from dg
-test
, and that
92 # it still stores the filename of the testcase in a local
variable "name".
93 # A cleaner solution would require a new DejaGnu release.
96 set suf
[dump
-suffix
[lindex $
args 3]]
97 set printable_pattern
[make_pattern_printable
[lindex $
args 1]]
98 set testname
"$testcase scan-[lindex $args 0]-dump-times $suf \"$printable_pattern\" [lindex $args 2]"
99 set src
[file tail
[lindex $testcase
0]]
100 set output_file
"[glob -nocomplain $src.[lindex $args 3]]"
101 if { $output_file
== "" } {
102 verbose
-log "$testcase: dump file does not exist"
103 unresolved
"$testname"
107 set fd
[open $output_file r
]
111 if { [llength
[regexp
-inline
-all
-- [lindex $
args 1] $
text]] == [lindex $
args 2]} {
118 #
Call pass
if pattern is not present
, otherwise fail.
120 #
Argument 0 is the type of dump we are searching
(rtl
, tree
, ipa
)
121 #
Argument 1 is the regexp to match.
122 #
Argument 2 is the suffix
for the dump file
123 #
Argument 3 handles expected failures and the like
124 proc scan
-dump
-not
{ args } {
126 if { [llength $
args] >= 4 } {
127 switch [dg
-process
-target
[lindex $
args 3]] {
130 "F" { setup_xfail "*-*-*" }
135 # This assumes that we are three frames down from dg
-test
, and that
136 # it still stores the filename of the testcase in a local
variable "name".
137 # A cleaner solution would require a new DejaGnu release.
138 upvar
3 name testcase
140 set suf
[dump
-suffix
[lindex $
args 2]]
141 set testname
"$testcase scan-[lindex $args 0]-dump-not $suf \"[lindex $args 1]\""
142 set src
[file tail
[lindex $testcase
0]]
143 set output_file
"[glob -nocomplain $src.[lindex $args 2]]"
144 if { $output_file
== "" } {
145 verbose
-log "$testcase: dump file does not exist"
146 unresolved
"$testname"
150 set fd
[open $output_file r
]
154 if ![regexp
-- [lindex $
args 1] $
text] {
161 # Utility
for scanning demangled compiler result
, invoked via dg
-final.
162 #
Call pass
if pattern is present
, otherwise fail.
164 #
Argument 0 is the type of dump we are searching
(rtl
, tree
, ipa
)
165 #
Argument 1 is the regexp to match.
166 #
Argument 2 is the suffix
for the dump file
167 #
Argument 3 handles expected failures and the like
168 proc scan
-dump
-dem
{ args } {
172 if { [llength $
args] >= 4 } {
173 switch [dg
-process
-target
[lindex $
args 3]] {
176 "F" { setup_xfail "*-*-*" }
181 # Find c
++filt like we find g
++ in g
++.exp.
182 if ![info exists cxxfilt
] {
183 set cxxfilt
[findfile $base_dir
/..
/..
/..
/binutils
/cxxfilt \
184 $base_dir
/..
/..
/..
/binutils
/cxxfilt \
185 [findfile $base_dir
/..
/..
/c
++filt $base_dir
/..
/..
/c
++filt \
186 [findfile $base_dir
/c
++filt $base_dir
/c
++filt \
187 [transform c
++filt
]]]]
188 verbose
-log "c++filt is $cxxfilt"
191 upvar
3 name testcase
192 set suf
[dump
-suffix
[lindex $
args 2]]
193 set testname
"$testcase scan-[lindex $args 0]-dump-dem $suf \"[lindex $args 1]\""
194 set src
[file tail
[lindex $testcase
0]]
195 set output_file
"[glob -nocomplain $src.[lindex $args 2]]"
196 if { $output_file
== "" } {
197 verbose
-log "$testcase: dump file does not exist"
198 unresolved
"$testname"
202 set fd
[open
"| $cxxfilt < $output_file" r]
206 if [regexp
-- [lindex $
args 1] $
text] {
213 #
Call pass
if demangled pattern is not present
, otherwise fail.
215 #
Argument 0 is the type of dump we are searching
(rtl
, tree
, ipa
)
216 #
Argument 1 is the regexp to match.
217 #
Argument 2 is the suffix
for the dump file
218 #
Argument 3 handles expected failures and the like
219 proc scan
-dump
-dem
-not
{ args } {
223 if { [llength $
args] >= 4 } {
224 switch [dg
-process
-target
[lindex $
args 3]] {
227 "F" { setup_xfail "*-*-*" }
232 # Find c
++filt like we find g
++ in g
++.exp.
233 if ![info exists cxxfilt
] {
234 set cxxfilt
[findfile $base_dir
/..
/..
/..
/binutils
/cxxfilt \
235 $base_dir
/..
/..
/..
/binutils
/cxxfilt \
236 [findfile $base_dir
/..
/..
/c
++filt $base_dir
/..
/..
/c
++filt \
237 [findfile $base_dir
/c
++filt $base_dir
/c
++filt \
238 [transform c
++filt
]]]]
239 verbose
-log "c++filt is $cxxfilt"
242 upvar
3 name testcase
244 set suf
[dump
-suffix
[lindex $
args 2]]
245 set testname
"$testcase scan-[lindex $args 0]-dump-dem-not $suf \"[lindex $args 1]\""
246 set src
[file tail
[lindex $testcase
0]]
247 set output_file
"[glob -nocomplain $src.[lindex $args 2]]"
248 if { $output_file
== "" } {
249 verbose
-log "$testcase: dump file does not exist"
250 unresolved
"$testname"
254 set fd
[open
"| $cxxfilt < $output_file" r]
258 if ![regexp
-- [lindex $
args 1] $
text] {