X-Git-Url: http://drtracing.org/?a=blobdiff_plain;f=binutils%2Ftestsuite%2Flib%2Futils-lib.exp;h=ace30e642732fdfa5c5cfcc8614645271f133cb1;hb=0b1352e04caa6b562a532354dc48f775e6a1135b;hp=2ea9f83605b73cc675f571477f3329b6a322a3f6;hpb=a6eed1d25f5fa83cfa4e56f2ac8e35792ab44266;p=deliverable%2Fbinutils-gdb.git diff --git a/binutils/testsuite/lib/utils-lib.exp b/binutils/testsuite/lib/utils-lib.exp index 2ea9f83605..ace30e6427 100644 --- a/binutils/testsuite/lib/utils-lib.exp +++ b/binutils/testsuite/lib/utils-lib.exp @@ -1,18 +1,18 @@ -# Copyright (C) 1993, 1994 Free Software Foundation, Inc. +# Copyright (C) 1993-2018 Free Software Foundation, Inc. # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or +# the Free Software Foundation; either version 3 of the License, or # (at your option) any later version. -# +# # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. -# +# # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +# Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. # Please email any bugs, comments, and/or additions to this file to: # bug-dejagnu@prep.ai.mit.edu @@ -20,74 +20,96 @@ # This file was written by Rob Savoye # and extended by Ian Lance Taylor +proc load_common_lib { name } { + load_lib $name +} + +load_common_lib binutils-common.exp + proc binutil_version { prog } { - if {[which $prog] == 0} then { - perror "$prog can't be run, file not found." - return "" + if ![is_remote host] { + set path [which $prog] + if {$path == 0} then { + perror "$prog can't be run, file not found." + return "" + } + } else { + set path $prog } - catch "exec $prog --version" tmp + set state [remote_exec host $prog --version] + set tmp "[lindex $state 1]\n" # Should find a way to discard constant parts, keep whatever's # left, so the version string could be almost anything at all... - regexp "version (cygnus-|)\[-0-9.a-zA-Z-\]+" $tmp version - if ![info exists version] then { - return "[which $prog] (no version number)\n" + regexp "\[^\n\]* (cygnus-|)(\[-0-9.a-zA-Z-\]+)\[\r\n\].*" "$tmp" version cyg number + if ![info exists number] then { + return "$path (no version number)\n" } - set tmp $version - return "[which $prog] $version\n" + return "$path $number\n" } # # default_binutils_run # run a program, returning the output # sets binutils_run_failed if the program does not exist +# sets binutils_run_status to the exit status of the program # proc default_binutils_run { prog progargs } { global binutils_run_failed + global binutils_run_status + global host_triplet set binutils_run_failed 0 + if [info exists binutils_run_status] { + unset binutils_run_status + } - if {[which $prog] == 0} then { - perror "$prog does not exist" - set binutils_run_failed 1 - return "" + if ![is_remote host] { + if {[which $prog] == 0} then { + perror "$prog does not exist" + set binutils_run_failed 1 + return "" + } + } + + # For objdump, automatically translate standard section + # names to the targets one, if they are different. + set sect_names [get_standard_section_names] + if { $sect_names != "" && [string match "*objdump" $prog] } { + regsub -- "-j \\.text" $progargs "-j [lindex $sect_names 0]" progargs + regsub -- "-j \\.data" $progargs "-j [lindex $sect_names 1]" progargs + regsub -- "-j \\.bss" $progargs "-j [lindex $sect_names 2]" progargs } send_log "$prog $progargs\n" verbose "$prog $progargs" - # This used to be - # catch "exec $prog $progargs" exec_output - # but that would evaluate $progargs twice, which would fail if - # any arguments started with `$'. This is a dismal hack to avoid - # this problem. I tried using - # catch { exec $prog $progargs } exec_output - # but that failed because $progargs was not split into words by - # exec. I don't know if this operation can be done correctly. No - # matter how hard I try, I can not convince myself that TCL is a - # language. - regsub -all "\\$" $progargs "\\$" progq - catch "exec $prog $progq" exec_output + # Gotta quote dollar-signs because they get mangled by the + # shell otherwise. + regsub -all "\\$" "$progargs" "\\$" progargs + + set state [remote_exec host $prog $progargs] + set binutils_run_status [lindex $state 0] + set exec_output [prune_warnings [lindex $state 1]] if {![string match "" $exec_output]} then { send_log "$exec_output\n" verbose "$exec_output" + } else { + if { [lindex $state 0] != 0 } { + set exec_output "$prog exited with status [lindex $state 0]" + send_log "$exec_output\n" + verbose "$exec_output" + } } return $exec_output } # -# default_binutils_assemble +# default_binutils_assemble_flags # assemble a file # -proc default_binutils_assemble { as source object } { - global ASFLAGS +proc default_binutils_assemble_flags { source object asflags } { global srcdir - - if {[which $as] == 0} then { - perror "$as does not exist" - return 0 - } - - if ![info exists ASFLAGS] { set ASFLAGS "" } + global host_triplet # The HPPA assembler syntax is a little different than most, to make # the test source file assemble we need to run it through sed. @@ -95,50 +117,41 @@ proc default_binutils_assemble { as source object } { # This is a hack in that it won't scale well if other targets need # similar transformations to assemble. We'll generalize the hack # if/when other targets need similar handling. - if [istarget "hppa*-*-*" ] then { - send_log "sed -f $srcdir/config/hppa.sed < $source | $as $ASFLAGS -o $object\n" - verbose "sed -f $srcdir/config/hppa.sed < $source | $as $ASFLAGS -o $object" - catch "exec sed -f $srcdir/config/hppa.sed < $source | $as $ASFLAGS -o $object" exec_output - } else { - send_log "$as $ASFLAGS -o $object $source\n" - verbose "$as $ASFLAGS -o $object $source" - catch "exec $as $ASFLAGS -o $object $source" exec_output + if { [istarget "hppa*-*-*"] \ + && ![istarget "*-*-linux*"] \ + && ![istarget "*-*-netbsd*" ] } { + set sed_file $srcdir/config/hppa.sed + send_log "sed -f $sed_file < $source > asm.s\n" + verbose "sed -f $sed_file < $source > asm.s" + catch "exec sed -f $sed_file < $source > asm.s" + set source asm.s } - set exec_output [prune_system_crud $host_triplet $exec_output] + set exec_output [target_assemble $source $object $asflags] + set exec_output [prune_warnings $exec_output] - if [string match "" $exec_output] then { + if [string match "" $exec_output] { return 1 } else { send_log "$exec_output\n" verbose "$exec_output" - perror "$source: assembly failed" return 0 } } -# This definition is taken from an unreleased version of DejaGnu. Once -# that version gets released, and has been out in the world for a few -# months at least, it may be safe to delete this copy. -if ![string length [info proc prune_system_crud]] { - # - # prune_system_crud -- delete various system verbosities from TEXT on SYSTEM - # - # An example is: - # ld.so: warning: /usr/lib/libc.so.1.8.1 has older revision than expected 9 - # - # SYSTEM is typical $target_triplet or $host_triplet. - # - # This is useful when trying to do pattern matches on program output. - # Sites with particular verbose os's may wish to override this in site.exp. - # - proc prune_system_crud { system text } { - # This is from sun4's. Do it for all machines for now. - # The "\\1" is to try to preserve a "\n" but only if necessary. - regsub -all "(^|\n)(ld.so: warning:\[^\n\]*\n?)+" $text "\\1" text - - # It might be tempting to get carried away and delete blank lines, etc. - # Just delete *exactly* what we're ask to, and that's it. - return $text +# +# exe_ext +# Returns target executable extension, if any. +# +proc exe_ext {} { + if { [istarget *-*-mingw*] || [istarget *-*-cygwin*] } { + return ".exe" + } else { + return "" } } + +proc verbose_eval { expr { level 1 } } { + global verbose + if $verbose>$level then { eval verbose "$expr" $level } +}