1 # Copyright
(C
) 2000, 2002, 2003 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.
, 59 Temple Place
- Suite
330, Boston
, MA
02111-1307, USA.
17 # Various utilities
for scanning tree 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 regexp to match.
26 #
Argument 1 is the suffix
for the tree dump file
27 #
Argument 2 handles expected failures and the like
28 proc scan
-tree
-dump
{ args } {
29 if { [llength $
args] < 2 } {
30 error
"scan-tree-dump: too few arguments"
33 if { [llength $
args] > 3 } {
34 error
"scan-tree-dump: too many arguments"
37 if { [llength $
args] >= 3 } {
38 switch [dg
-process
-target
[lindex $
args 2]] {
41 "F" { setup_xfail "*-*-*" }
46 # This assumes that we are two frames down from dg
-test
, and that
47 # it still stores the filename of the testcase in a local
variable "name".
48 # A cleaner solution would require a new dejagnu release.
51 # This must match the rule in gcc
-dg.exp.
52 set output_file
"[glob [file tail $testcase].t??.[lindex $args 1]]"
54 set fd
[open $output_file r
]
58 if [regexp
-- [lindex $
args 0] $
text] {
59 pass
"$testcase scan-tree-dump [lindex $args 0]"
61 fail
"$testcase scan-tree-dump [lindex $args 0]"
65 #
Call pass
if pattern is present given number of times
, otherwise fail.
66 #
Argument 0 is the regexp to match.
67 #
Argument 1 is number of times the regexp must be found
68 #
Argument 2 is the suffix
for the tree dump file
69 #
Argument 3 handles expected failures and the like
70 proc scan
-tree
-dump
-times
{ args } {
71 if { [llength $
args] < 3 } {
72 error
"scan-tree-dump: too few arguments"
75 if { [llength $
args] > 4 } {
76 error
"scan-tree-dump: too many arguments"
79 if { [llength $
args] >= 4 } {
80 switch [dg
-process
-target
[lindex $
args 3]] {
83 "F" { setup_xfail "*-*-*" }
88 # This assumes that we are two frames down from dg
-test
, and that
89 # it still stores the filename of the testcase in a local
variable "name".
90 # A cleaner solution would require a new dejagnu release.
93 # This must match the rule in gcc
-dg.exp.
94 set output_file
"[glob [file tail $testcase].t??.[lindex $args 2]]"
96 set fd
[open $output_file r
]
100 if { [llength
[regexp
-inline
-all
-- [lindex $
args 0] $
text]] == [lindex $
args 1]} {
101 pass
"$testcase scan-tree-dump-times [lindex $args 0] [lindex $args 1]"
103 fail
"$testcase scan-tree-dump-times [lindex $args 0] [lindex $args 1]"
107 #
Call pass
if pattern is not present
, otherwise fail.
109 #
Argument 0 is the regexp to match.
110 #
Argument 1 is the suffix
for the tree dump file
111 #
Argument 2 handles expected failures and the like
112 proc scan
-tree
-dump
-not
{ args } {
113 if { [llength $
args] < 2 } {
114 error
"scan-tree-dump-not: too few arguments"
117 if { [llength $
args] > 3 } {
118 error
"scan-tree-dump-not: too many arguments"
121 if { [llength $
args] >= 3 } {
122 switch [dg
-process
-target
[lindex $
args 2]] {
125 "F" { setup_xfail "*-*-*" }
130 upvar
2 name testcase
131 set output_file
"[glob [file tail $testcase].t??.[lindex $args 1]]"
133 set fd
[open $output_file r
]
137 if ![regexp
-- [lindex $
args 0] $
text] {
138 pass
"$testcase scan-tree-dump-not [lindex $args 0]"
140 fail
"$testcase scan-tree-dump-not [lindex $args 0]"
144 # Utility
for scanning demangled compiler result
, invoked via dg
-final.
145 #
Call pass
if pattern is present
, otherwise fail.
147 #
Argument 0 is the regexp to match.
148 #
Argument 1 is the suffix
for the tree dump file
149 #
Argument 2 handles expected failures and the like
150 proc scan
-tree
-dump
-dem
{ args } {
154 if { [llength $
args] < 2 } {
155 error
"scan-tree-dump-dem: too few arguments"
158 if { [llength $
args] > 3 } {
159 error
"scan-tree-dump-dem: too many arguments"
162 if { [llength $
args] >= 3 } {
163 switch [dg
-process
-target
[lindex $
args 2]] {
166 "F" { setup_xfail "*-*-*" }
171 # Find c
++filt like we find g
++ in g
++.exp.
172 if ![info exists cxxfilt
] {
173 set cxxfilt
[findfile $base_dir
/..
/..
/binutils
/cxxfilt \
174 $base_dir
/..
/..
/binutils
/cxxfilt \
175 [findfile $base_dir
/..
/c
++filt $base_dir
/..
/c
++filt \
176 [findfile $base_dir
/c
++filt $base_dir
/c
++filt \
177 [transform c
++filt
]]]]
178 verbose
-log "c++filt is $cxxfilt"
181 upvar
2 name testcase
182 set output_file
"[glob [file tail $testcase].t??.[lindex $args 1]]"
184 set fd
[open
"| $cxxfilt < $output_file" r]
188 if [regexp
-- [lindex $
args 0] $
text] {
189 pass
"$testcase scan-tree-dump-dem [lindex $args 0]"
191 fail
"$testcase scan-tree-dump-dem [lindex $args 0]"
195 #
Call pass
if demangled pattern is not present
, otherwise fail.
197 #
Argument 0 is the regexp to match.
198 #
Argument 1 is the suffix
for the tree dump file
199 #
Argument 2 handles expected failures and the like
200 proc scan
-tree
-dump
-dem
-not
{ args } {
204 if { [llength $
args] < 2 } {
205 error
"scan-tree-dump-dem-not: too few arguments"
208 if { [llength $
args] > 3 } {
209 error
"scan-tree-dump-dem-not: too many arguments"
212 if { [llength $
args] >= 3 } {
213 switch [dg
-process
-target
[lindex $
args 2]] {
216 "F" { setup_xfail "*-*-*" }
221 # Find c
++filt like we find g
++ in g
++.exp.
222 if ![info exists cxxfilt
] {
223 set cxxfilt
[findfile $base_dir
/..
/..
/binutils
/cxxfilt \
224 $base_dir
/..
/..
/binutils
/cxxfilt \
225 [findfile $base_dir
/..
/c
++filt $base_dir
/..
/c
++filt \
226 [findfile $base_dir
/c
++filt $base_dir
/c
++filt \
227 [transform c
++filt
]]]]
228 verbose
-log "c++filt is $cxxfilt"
231 upvar
2 name testcase
232 set output_file
"[glob [file tail $testcase].t??.[lindex $args 1]]"
234 set fd
[open
"| $cxxfilt < $output_file" r]
238 if ![regexp
-- [lindex $
args 0] $
text] {
239 pass
"$testcase scan-tree-dump-dem-not [lindex $args 0]"
241 fail
"$testcase scan-tree-dump-dem-not [lindex $args 0]"