1 # Copyright
(C
) 2000, 2002, 2003, 2005, 2007 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
3 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 GCC
; see the file COPYING3.
If not see
15 #
<http
://www.gnu.org
/licenses
/>.
17 # Various utilities
for scanning dump output
, used by gcc
-dg.exp and
20 # This is largely borrowed from scanasm.exp.
22 # Extract the constant part of the dump file suffix from the regexp.
23 #
Argument 0 is the regular expression.
24 proc dump
-suffix
{ arg } {
25 set idx
[expr
[string last
"." $arg] + 1]
26 return [string range $
arg $idx end
]
29 # Utility
for scanning compiler result
, invoked via dg
-final.
30 #
Call pass
if pattern is present
, otherwise fail.
32 #
Argument 0 is the type of dump we are searching
(rtl
, tree
, ipa
)
33 #
Argument 1 is the regexp to match.
34 #
Argument 2 is the suffix
for the dump file
35 #
Argument 3 handles expected failures and the like
36 proc scan
-dump
{ args } {
38 if { [llength $
args] >= 4 } {
39 switch [dg
-process
-target
[lindex $
args 3]] {
42 "F" { setup_xfail "*-*-*" }
47 # This assumes that we are three frames down from dg
-test
, and that
48 # it still stores the filename of the testcase in a local
variable "name".
49 # A cleaner solution would require a new DejaGnu release.
52 set suf
[dump
-suffix
[lindex $
args 2]]
53 set testname
"$testcase scan-[lindex $args 0]-dump $suf \"[lindex $args 1]\""
54 set src
[file tail
[lindex $testcase
0]]
55 set output_file
"[glob -nocomplain $src.[lindex $args 2]]"
56 if { $output_file
== "" } {
57 fail
"$testname: dump file does not exist"
61 set fd
[open $output_file r
]
65 if [regexp
-- [lindex $
args 1] $
text] {
72 #
Call pass
if pattern is present given number of times
, otherwise fail.
73 #
Argument 0 is the type of dump we are searching
(rtl
, tree
, ipa
)
74 #
Argument 1 is the regexp to match.
75 #
Argument 2 is number of times the regexp must be found
76 #
Argument 3 is the suffix
for the dump file
77 #
Argument 4 handles expected failures and the like
78 proc scan
-dump
-times
{ args } {
80 if { [llength $
args] >= 5 } {
81 switch [dg
-process
-target
[lindex $
args 4]] {
84 "F" { setup_xfail "*-*-*" }
89 # This assumes that we are three frames down from dg
-test
, and that
90 # it still stores the filename of the testcase in a local
variable "name".
91 # A cleaner solution would require a new DejaGnu release.
94 set suf
[dump
-suffix
[lindex $
args 3]]
95 set testname
"$testcase scan-[lindex $args 0]-dump-times $suf \"[lindex $args 1]\" [lindex $args 2]"
96 set src
[file tail
[lindex $testcase
0]]
97 set output_file
"[glob -nocomplain $src.[lindex $args 3]]"
98 if { $output_file
== "" } {
99 fail
"$testname: dump file does not exist"
103 set fd
[open $output_file r
]
107 if { [llength
[regexp
-inline
-all
-- [lindex $
args 1] $
text]] == [lindex $
args 2]} {
114 #
Call pass
if pattern is not present
, otherwise fail.
116 #
Argument 0 is the type of dump we are searching
(rtl
, tree
, ipa
)
117 #
Argument 1 is the regexp to match.
118 #
Argument 2 is the suffix
for the dump file
119 #
Argument 3 handles expected failures and the like
120 proc scan
-dump
-not
{ args } {
122 if { [llength $
args] >= 4 } {
123 switch [dg
-process
-target
[lindex $
args 3]] {
126 "F" { setup_xfail "*-*-*" }
131 # This assumes that we are three frames down from dg
-test
, and that
132 # it still stores the filename of the testcase in a local
variable "name".
133 # A cleaner solution would require a new DejaGnu release.
134 upvar
3 name testcase
136 set suf
[dump
-suffix
[lindex $
args 2]]
137 set testname
"$testcase scan-[lindex $args 0]-dump-not $suf \"[lindex $args 1]\""
138 set src
[file tail
[lindex $testcase
0]]
139 set output_file
"[glob -nocomplain $src.[lindex $args 2]]"
140 if { $output_file
== "" } {
141 fail
"$testname: dump file does not exist"
145 set fd
[open $output_file r
]
149 if ![regexp
-- [lindex $
args 1] $
text] {
156 # Utility
for scanning demangled compiler result
, invoked via dg
-final.
157 #
Call pass
if pattern is present
, otherwise fail.
159 #
Argument 0 is the type of dump we are searching
(rtl
, tree
, ipa
)
160 #
Argument 1 is the regexp to match.
161 #
Argument 2 is the suffix
for the dump file
162 #
Argument 3 handles expected failures and the like
163 proc scan
-dump
-dem
{ args } {
167 if { [llength $
args] >= 4 } {
168 switch [dg
-process
-target
[lindex $
args 3]] {
171 "F" { setup_xfail "*-*-*" }
176 # Find c
++filt like we find g
++ in g
++.exp.
177 if ![info exists cxxfilt
] {
178 set cxxfilt
[findfile $base_dir
/..
/..
/..
/binutils
/cxxfilt \
179 $base_dir
/..
/..
/..
/binutils
/cxxfilt \
180 [findfile $base_dir
/..
/..
/c
++filt $base_dir
/..
/..
/c
++filt \
181 [findfile $base_dir
/c
++filt $base_dir
/c
++filt \
182 [transform c
++filt
]]]]
183 verbose
-log "c++filt is $cxxfilt"
186 upvar
3 name testcase
187 set suf
[dump
-suffix
[lindex $
args 2]]
188 set testname
"$testcase scan-[lindex $args 0]-dump-dem $suf \"[lindex $args 1]\""
189 set src
[file tail
[lindex $testcase
0]]
190 set output_file
"[glob -nocomplain $src.[lindex $args 2]]"
191 if { $output_file
== "" } {
192 fail
"$testname: dump file does not exist"
196 set fd
[open
"| $cxxfilt < $output_file" r]
200 if [regexp
-- [lindex $
args 1] $
text] {
207 #
Call pass
if demangled pattern is not present
, otherwise fail.
209 #
Argument 0 is the type of dump we are searching
(rtl
, tree
, ipa
)
210 #
Argument 1 is the regexp to match.
211 #
Argument 2 is the suffix
for the dump file
212 #
Argument 3 handles expected failures and the like
213 proc scan
-dump
-dem
-not
{ args } {
217 if { [llength $
args] >= 4 } {
218 switch [dg
-process
-target
[lindex $
args 3]] {
221 "F" { setup_xfail "*-*-*" }
226 # Find c
++filt like we find g
++ in g
++.exp.
227 if ![info exists cxxfilt
] {
228 set cxxfilt
[findfile $base_dir
/..
/..
/..
/binutils
/cxxfilt \
229 $base_dir
/..
/..
/..
/binutils
/cxxfilt \
230 [findfile $base_dir
/..
/..
/c
++filt $base_dir
/..
/..
/c
++filt \
231 [findfile $base_dir
/c
++filt $base_dir
/c
++filt \
232 [transform c
++filt
]]]]
233 verbose
-log "c++filt is $cxxfilt"
236 upvar
3 name testcase
238 set suf
[dump
-suffix
[lindex $
args 2]]
239 set testname
"$testcase scan-[lindex $args 0]-dump-dem-not $suf \"[lindex $args 1]\""
240 set src
[file tail
[lindex $testcase
0]]
241 set output_file
"[glob -nocomplain $src.[lindex $args 2]]"
242 if { $output_file
== "" } {
243 fail
"$testname: dump file does not exist"
247 set fd
[open
"| $cxxfilt < $output_file" r]
251 if ![regexp
-- [lindex $
args 1] $
text] {