1 # Copyright
(C
) 2000-2017 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 first
"." $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 set testcase
[testname
-for-summary
]
48 # The
name might
include a list of options
; extract the file
name.
49 set filename
[lindex $testcase
0]
51 set printable_pattern
[make_pattern_printable
[lindex $
args 1]]
52 set suf
[dump
-suffix
[lindex $
args 2]]
53 set testname
"$testcase scan-[lindex $args 0]-dump $suf \"$printable_pattern\""
54 set src
[file tail $filename
]
55 set output_file
"[glob -nocomplain $src.[lindex $args 2]]"
56 if { $output_file
== "" } {
57 verbose
-log "$testcase: dump file does not exist"
58 unresolved
"$testname"
62 set fd
[open $output_file r
]
66 if [regexp
-- [lindex $
args 1] $
text] {
73 #
Call pass
if pattern is present given number of times
, otherwise fail.
74 #
Argument 0 is the type of dump we are searching
(rtl
, tree
, ipa
)
75 #
Argument 1 is the regexp to match.
76 #
Argument 2 is number of times the regexp must be found
77 #
Argument 3 is the suffix
for the dump file
78 #
Argument 4 handles expected failures and the like
79 proc scan
-dump
-times
{ args } {
81 if { [llength $
args] >= 5 } {
82 switch [dg
-process
-target
[lindex $
args 4]] {
85 "F" { setup_xfail "*-*-*" }
90 set testcase
[testname
-for-summary
]
91 # The
name might
include a list of options
; extract the file
name.
92 set filename
[lindex $testcase
0]
93 set times
[lindex $
args 2]
94 set suf
[dump
-suffix
[lindex $
args 3]]
95 set printable_pattern
[make_pattern_printable
[lindex $
args 1]]
96 set testname
"$testcase scan-[lindex $args 0]-dump-times $suf \"$printable_pattern\" [lindex $args 2]"
97 set src
[file tail $filename
]
98 set output_file
"[glob -nocomplain $src.[lindex $args 3]]"
99 if { $output_file
== "" } {
100 verbose
-log "$testcase: dump file does not exist"
101 unresolved
"$testname"
105 set fd
[open $output_file r
]
109 set result_count
[llength
[regexp
-inline
-all
-- [lindex $
args 1] $
text]]
110 if {$result_count
== $times
} {
113 fail
"$testname (found $result_count times)"
117 #
Call pass
if pattern is not present
, otherwise fail.
119 #
Argument 0 is the type of dump we are searching
(rtl
, tree
, ipa
)
120 #
Argument 1 is the regexp to match.
121 #
Argument 2 is the suffix
for the dump file
122 #
Argument 3 handles expected failures and the like
123 proc scan
-dump
-not
{ args } {
125 if { [llength $
args] >= 4 } {
126 switch [dg
-process
-target
[lindex $
args 3]] {
129 "F" { setup_xfail "*-*-*" }
134 set testcase
[testname
-for-summary
]
135 # The
name might
include a list of options
; extract the file
name.
136 set filename
[lindex $testcase
0]
137 set printable_pattern
[make_pattern_printable
[lindex $
args 1]]
138 set suf
[dump
-suffix
[lindex $
args 2]]
139 set testname
"$testcase scan-[lindex $args 0]-dump-not $suf \"$printable_pattern\""
140 set src
[file tail $filename
]
141 set output_file
"[glob -nocomplain $src.[lindex $args 2]]"
142 if { $output_file
== "" } {
143 verbose
-log "$testcase: dump file does not exist"
144 unresolved
"$testname"
148 set fd
[open $output_file r
]
152 if ![regexp
-- [lindex $
args 1] $
text] {
159 # Utility
for scanning demangled compiler result
, invoked via dg
-final.
160 #
Call pass
if pattern is present
, otherwise fail.
162 #
Argument 0 is the type of dump we are searching
(rtl
, tree
, ipa
)
163 #
Argument 1 is the regexp to match.
164 #
Argument 2 is the suffix
for the dump file
165 #
Argument 3 handles expected failures and the like
166 proc scan
-dump
-dem
{ args } {
170 if { [llength $
args] >= 4 } {
171 switch [dg
-process
-target
[lindex $
args 3]] {
174 "F" { setup_xfail "*-*-*" }
179 # Find c
++filt like we find g
++ in g
++.exp.
180 if ![info exists cxxfilt
] {
181 set cxxfilt
[findfile $base_dir
/..
/..
/..
/binutils
/cxxfilt \
182 $base_dir
/..
/..
/..
/binutils
/cxxfilt \
183 [findfile $base_dir
/..
/..
/c
++filt $base_dir
/..
/..
/c
++filt \
184 [findfile $base_dir
/c
++filt $base_dir
/c
++filt \
185 [transform c
++filt
]]]]
186 verbose
-log "c++filt is $cxxfilt"
189 set testcase
[testname
-for-summary
]
190 # The
name might
include a list of options
; extract the file
name.
191 set filename
[lindex $testcase
0]
192 set printable_pattern
[make_pattern_printable
[lindex $
args 1]]
193 set suf
[dump
-suffix
[lindex $
args 2]]
194 set testname
"$testcase scan-[lindex $args 0]-dump-dem $suf \"$printable_pattern\""
195 set src
[file tail $filename
]
196 set output_file
"[glob -nocomplain $src.[lindex $args 2]]"
197 if { $output_file
== "" } {
198 verbose
-log "$testcase: dump file does not exist"
199 unresolved
"$testname"
203 set fd
[open
"| $cxxfilt < $output_file" r]
207 if [regexp
-- [lindex $
args 1] $
text] {
214 #
Call pass
if demangled pattern is not present
, otherwise fail.
216 #
Argument 0 is the type of dump we are searching
(rtl
, tree
, ipa
)
217 #
Argument 1 is the regexp to match.
218 #
Argument 2 is the suffix
for the dump file
219 #
Argument 3 handles expected failures and the like
220 proc scan
-dump
-dem
-not
{ args } {
224 if { [llength $
args] >= 4 } {
225 switch [dg
-process
-target
[lindex $
args 3]] {
228 "F" { setup_xfail "*-*-*" }
233 # Find c
++filt like we find g
++ in g
++.exp.
234 if ![info exists cxxfilt
] {
235 set cxxfilt
[findfile $base_dir
/..
/..
/..
/binutils
/cxxfilt \
236 $base_dir
/..
/..
/..
/binutils
/cxxfilt \
237 [findfile $base_dir
/..
/..
/c
++filt $base_dir
/..
/..
/c
++filt \
238 [findfile $base_dir
/c
++filt $base_dir
/c
++filt \
239 [transform c
++filt
]]]]
240 verbose
-log "c++filt is $cxxfilt"
243 set testcase
[testname
-for-summary
]
244 # The
name might
include a list of options
; extract the file
name.
245 set filename
[lindex $testcase
0]
246 set printable_pattern
[make_pattern_printable
[lindex $
args 1]
247 set suf
[dump
-suffix
[lindex $
args 2]]
248 set testname
"$testcase scan-[lindex $args 0]-dump-dem-not $suf \"$printable_pattern\""
249 set src
[file tail $filename
]
250 set output_file
"[glob -nocomplain $src.[lindex $args 2]]"
251 if { $output_file
== "" } {
252 verbose
-log "$testcase: dump file does not exist"
253 unresolved
"$testname"
257 set fd
[open
"| $cxxfilt < $output_file" r]
261 if ![regexp
-- [lindex $
args 1] $
text] {