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 assembler output
, used by gcc
-dg.exp and
20 # Utility
for scanning compiler result
, invoked via dg
-final.
22 # Scan the OUTPUT_FILE
for a pattern.
If it is present and POSITIVE
23 # is non
-zero
, or it is not present and POSITIVE is zero
, the test
24 # passes. The ORIG_ARGS is the list of arguments provided by dg
-final
25 # to scan
-assembler. The first element in ORIG_ARGS is the regular
26 # expression to look
for in the file. The second element
, if present
,
27 # is a DejaGNU target selector.
29 proc dg
-scan
{ name positive testcase output_file orig_args
} {
30 if { [llength $orig_args
] < 1 } {
31 error
"$name: too few arguments"
34 if { [llength $orig_args
] > 2 } {
35 error
"$name: too many arguments"
38 if { [llength $orig_args
] >= 2 } {
39 switch [dg
-process
-target
[lindex $orig_args
1]] {
42 "F" { setup_xfail "*-*-*" }
47 set fd
[open $output_file r
]
51 set pattern
[lindex $orig_args
0]
52 set printable_pattern
[string map
{\t \\t
\n \\n
\r \\r
\\ \\\\} $pattern
]
54 set match
[regexp
-- $pattern $
text]
55 if { $match
== $positive
} {
56 pass
"$testcase $name $printable_pattern"
58 fail
"$testcase $name $printable_pattern"
62 # Look
for a pattern in the .s file produced by the compiler. See
63 # dg
-scan
for details.
65 proc scan
-assembler
{ args } {
67 set output_file
"[file rootname [file tail $testcase]].s"
69 dg
-scan
"scan-assembler" 1 $testcase $output_file $args
72 # Check that a pattern is not present in the .s file produced by the
73 # compiler. See dg
-scan
for details.
75 proc scan
-assembler
-not
{ args } {
77 set output_file
"[file rootname [file tail $testcase]].s"
79 dg
-scan
"scan-assembler-not" 0 $testcase $output_file $args
82 # Check that a symbol is defined as a hidden symbol in the .s file
83 # produced by the compiler.
85 proc scan
-hidden
{ args } {
87 set output_file
"[file rootname [file tail $testcase]].s"
89 set symbol
[lindex $
args 0]
90 set args [lreplace $
args 0 0 "hidden\[ \t_\]*$symbol"]
92 dg
-scan
"scan-hidden" 1 $testcase $output_file $args
95 # Check that a symbol is not defined as a hidden symbol in the .s file
96 # produced by the compiler.
98 proc scan
-not
-hidden
{ args } {
100 set output_file
"[file rootname [file tail $testcase]].s"
102 set symbol
[lindex $
args 0]
103 set args [lreplace $
args 0 0 "hidden\[ \t_\]*$symbol"]
105 dg
-scan
"scan-not-hidden" 0 $testcase $output_file $args
108 # Look
for a pattern in OUTPUT_FILE. See dg
-scan
for details.
110 proc scan
-file
{ output_file
args } {
111 upvar
2 name testcase
112 dg
-scan
"scan-file" 1 $testcase $output_file $args
115 # Check that a pattern is not present in the OUTPUT_FILE. See dg
-scan
118 proc scan
-file
-not
{ output_file
args } {
119 upvar
2 name testcase
120 dg
-scan
"scan-file-not" 0 $testcase $output_file $args
123 #
Call pass
if pattern is present given number of times
, otherwise fail.
124 proc scan
-assembler
-times
{ args } {
125 if { [llength $
args] < 2 } {
126 error
"scan-assembler: too few arguments"
129 if { [llength $
args] > 3 } {
130 error
"scan-assembler: too many arguments"
133 if { [llength $
args] >= 3 } {
134 switch [dg
-process
-target
[lindex $
args 2]] {
137 "F" { setup_xfail "*-*-*" }
142 # This assumes that we are two frames down from dg
-test
, and that
143 # it still stores the filename of the testcase in a local
variable "name".
144 # A cleaner solution would require a new dejagnu release.
145 upvar
2 name testcase
147 # This must match the rule in gcc
-dg.exp.
148 set output_file
"[file rootname [file tail $testcase]].s"
150 set fd
[open $output_file r
]
154 if { [llength
[regexp
-inline
-all
-- [lindex $
args 0] $
text]] == [lindex $
args 1]} {
155 pass
"$testcase scan-assembler-times [lindex $args 0] [lindex $args 1]"
157 fail
"$testcase scan-assembler-times [lindex $args 0] [lindex $args 1]"
161 # Utility
for scanning demangled compiler result
, invoked via dg
-final.
162 #
Call pass
if pattern is present
, otherwise fail.
163 proc scan
-assembler
-dem
{ args } {
167 if { [llength $
args] < 1 } {
168 error
"scan-assembler-dem: too few arguments"
171 if { [llength $
args] > 2 } {
172 error
"scan-assembler-dem: too many arguments"
175 if { [llength $
args] >= 2 } {
176 switch [dg
-process
-target
[lindex $
args 1]] {
179 "F" { setup_xfail "*-*-*" }
184 # Find c
++filt like we find g
++ in g
++.exp.
185 if ![info exists cxxfilt
] {
186 set cxxfilt
[findfile $base_dir
/..
/..
/binutils
/cxxfilt \
187 $base_dir
/..
/..
/binutils
/cxxfilt \
188 [findfile $base_dir
/..
/c
++filt $base_dir
/..
/c
++filt \
189 [findfile $base_dir
/c
++filt $base_dir
/c
++filt \
190 [transform c
++filt
]]]]
191 verbose
-log "c++filt is $cxxfilt"
194 upvar
2 name testcase
195 set output_file
"[file rootname [file tail $testcase]].s"
197 set fd
[open
"| $cxxfilt < $output_file" r]
201 if [regexp
-- [lindex $
args 0] $
text] {
202 pass
"$testcase scan-assembler-dem [lindex $args 0]"
204 fail
"$testcase scan-assembler-dem [lindex $args 0]"
208 #
Call pass
if demangled pattern is not present
, otherwise fail.
209 proc scan
-assembler
-dem
-not
{ args } {
213 if { [llength $
args] < 1 } {
214 error
"scan-assembler-dem-not: too few arguments"
217 if { [llength $
args] > 2 } {
218 error
"scan-assembler-dem-not: too many arguments"
221 if { [llength $
args] >= 2 } {
222 switch [dg
-process
-target
[lindex $
args 1]] {
225 "F" { setup_xfail "*-*-*" }
230 # Find c
++filt like we find g
++ in g
++.exp.
231 if ![info exists cxxfilt
] {
232 set cxxfilt
[findfile $base_dir
/..
/..
/binutils
/cxxfilt \
233 $base_dir
/..
/..
/binutils
/cxxfilt \
234 [findfile $base_dir
/..
/c
++filt $base_dir
/..
/c
++filt \
235 [findfile $base_dir
/c
++filt $base_dir
/c
++filt \
236 [transform c
++filt
]]]]
237 verbose
-log "c++filt is $cxxfilt"
240 upvar
2 name testcase
241 set output_file
"[file rootname [file tail $testcase]].s"
243 set fd
[open
"| $cxxfilt < $output_file" r]
247 if ![regexp
-- [lindex $
args 0] $
text] {
248 pass
"$testcase scan-assembler-dem-not [lindex $args 0]"
250 fail
"$testcase scan-assembler-dem-not [lindex $args 0]"