diff options
author | Michael Chastain <mec@google.com> | 2004-01-24 21:59:03 +0000 |
---|---|---|
committer | Michael Chastain <mec@google.com> | 2004-01-24 21:59:03 +0000 |
commit | 94b8e87660af2e95f13cb24b5b7949c7dde6bd3c (patch) | |
tree | 0b65e7948a05ce86f86f4c1a296b48426b093e55 | |
parent | 690668cc17e520a86c33bdab8badc91926e5a410 (diff) | |
download | gdb-94b8e87660af2e95f13cb24b5b7949c7dde6bd3c.zip gdb-94b8e87660af2e95f13cb24b5b7949c7dde6bd3c.tar.gz gdb-94b8e87660af2e95f13cb24b5b7949c7dde6bd3c.tar.bz2 |
2004-01-24 Michael Chastain <mec.gnu@mindspring.com>
* lib/compiler.c: Add hp_cc_compiler and hp_aCC_compiler.
* lib/compiler.cc: Likewise.
* lib/gdb.exp (get_compiler_info): Always call gdb_compile to
get the right preprocessor. Eval the output directly. Remove
special tests for hp_cc_compiler and hp_aCC_compiler. Remove
hp_f77_compiler and hp_f90_compiler completely.
(gdb_preprocess): Delete.
(get_compiler): Delete.
-rw-r--r-- | gdb/testsuite/ChangeLog | 11 | ||||
-rw-r--r-- | gdb/testsuite/lib/compiler.c | 57 | ||||
-rw-r--r-- | gdb/testsuite/lib/compiler.cc | 40 | ||||
-rw-r--r-- | gdb/testsuite/lib/gdb.exp | 241 |
4 files changed, 164 insertions, 185 deletions
diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog index 8a0e54f..d857fce 100644 --- a/gdb/testsuite/ChangeLog +++ b/gdb/testsuite/ChangeLog @@ -1,3 +1,14 @@ +2004-01-24 Michael Chastain <mec.gnu@mindspring.com> + + * lib/compiler.c: Add hp_cc_compiler and hp_aCC_compiler. + * lib/compiler.cc: Likewise. + * lib/gdb.exp (get_compiler_info): Always call gdb_compile to + get the right preprocessor. Eval the output directly. Remove + special tests for hp_cc_compiler and hp_aCC_compiler. Remove + hp_f77_compiler and hp_f90_compiler completely. + (gdb_preprocess): Delete. + (get_compiler): Delete. + 2004-01-24 Mark Kettenis <kettenis@gnu.org> * gdb.base/charset.c, gdb.base/dump.c, gdb.base/huge.c: Include diff --git a/gdb/testsuite/lib/compiler.c b/gdb/testsuite/lib/compiler.c index b0f557c..b1f1f5d 100644 --- a/gdb/testsuite/lib/compiler.c +++ b/gdb/testsuite/lib/compiler.c @@ -1,6 +1,6 @@ /* This test file is part of GDB, the GNU debugger. - Copyright 1995, 1997, 1999, 2003 Free Software Foundation, Inc. + Copyright 1995, 1997, 1999, 2003, 2004 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 @@ -19,36 +19,47 @@ Please email any bugs, comments, and/or additions to this file to: bug-gdb@prep.ai.mit.edu */ -/* Often the behavior of any particular test depends upon what compiler was - used to compile the test. As each test is compiled, this file is - preprocessed by the same compiler used to compile that specific test - (different tests might be compiled by different compilers, particularly - if compiled at different times), and used to generate a *.ci (compiler - info) file for that test. +/* Sometimes the behavior of a test depends upon the compiler used to + compile the test program. A test script can call get_compiler_info + to figure out the compiler version and test_compiler_info to test it. - I.E., when callfuncs is compiled, a callfuncs.ci file will be generated, - which can then be sourced by callfuncs.exp to give callfuncs.exp access - to information about the compilation environment. + get_compiler_info runs the preprocessor on this file and then eval's + the result. This sets various symbols for use by test_compiler_info. - TODO: It might be a good idea to add expect code that tests each - definition made with 'set" to see if one already exists, and if so - warn about conflicts if it is being set to something else. */ + TODO: make compiler_info a local variable for get_compiler_info and + test_compiler_info. -/* This needs to be kept in sync with whatis.c and gdb.exp(get_compiler_info). - If this ends up being hairy, we could use a common header file. */ + TODO: all clients should use test_compiler_info and should not + use gcc_compiled, hp_cc_compiler, or hp_aCC_compiler. -#if defined (__STDC__) || defined (_AIX) -set signed_keyword_not_used 0 -#else -set signed_keyword_not_used 1 -#endif + TODO: purge signed_keyword_not_used. */ + +set compiler_info "" #if defined (__GNUC__) -set gcc_compiled __GNUC__ set compiler_info [join {gcc __GNUC__ __GNUC_MINOR__ } -] +set gcc_compiled __GNUC__ #else set gcc_compiled 0 -set compiler_info "" #endif -return 0 +#if defined (__HP_cc) +set compiler_info [join {hpcc __HP_cc} -] +set hp_cc_compiler __HP_cc +#else +set hp_cc_compiler 0 +#endif + +#if defined (__HP_aCC) +set compiler_info [join {hpacc __HP_aCC} -] +set hp_aCC_compiler __HP_aCC +#else +set hp_aCC_compiler 0 +#endif + +/* gdb.base/whatis.exp still uses this */ +#if defined (__STDC__) || defined (_AIX) +set signed_keyword_not_used 0 +#else +set signed_keyword_not_used 1 +#endif diff --git a/gdb/testsuite/lib/compiler.cc b/gdb/testsuite/lib/compiler.cc index bbefeaa..0c5eb66 100644 --- a/gdb/testsuite/lib/compiler.cc +++ b/gdb/testsuite/lib/compiler.cc @@ -19,27 +19,35 @@ Please email any bugs, comments, and/or additions to this file to: bug-gdb@prep.ai.mit.edu */ -/* Often the behavior of any particular test depends upon what compiler was - used to compile the test. As each test is compiled, this file is - preprocessed by the same compiler used to compile that specific test - (different tests might be compiled by different compilers, particularly - if compiled at different times), and used to generate a *.ci (compiler - info) file for that test. +/* This file is exactly like compiler.c. I could just use compiler.c if + I could be sure that every C++ compiler accepted extensions of ".c". */ - I.E., when callfuncs is compiled, a callfuncs.ci file will be generated, - which can then be sourced by callfuncs.exp to give callfuncs.exp access - to information about the compilation environment. - - TODO: It might be a good idea to add expect code that tests each - definition made with 'set" to see if one already exists, and if so - warn about conflicts if it is being set to something else. */ +set compiler_info "" #if defined (__GNUC__) -set gcc_compiled __GNUC__ set compiler_info [join {gcc __GNUC__ __GNUC_MINOR__ } -] +set gcc_compiled __GNUC__ #else set gcc_compiled 0 -set compiler_info "" #endif -return 0 +#if defined (__HP_cc) +set compiler_info [join {hpcc __HP_cc} -] +set hp_cc_compiler __HP_cc +#else +set hp_cc_compiler 0 +#endif + +#if defined (__HP_aCC) +set compiler_info [join {hpacc __HP_aCC} -] +set hp_aCC_compiler __HP_aCC +#else +set hp_aCC_compiler 0 +#endif + +/* gdb.base/whatis.exp still uses this */ +#if defined (__STDC__) || defined (_AIX) +set signed_keyword_not_used 0 +#else +set signed_keyword_not_used 1 +#endif diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp index 3f2938e..9670c34 100644 --- a/gdb/testsuite/lib/gdb.exp +++ b/gdb/testsuite/lib/gdb.exp @@ -1,5 +1,5 @@ # Copyright 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, -# 2002, 2003 +# 2002, 2003, 2004 # Free Software Foundation, Inc. # This program is free software; you can redistribute it and/or modify @@ -1094,86 +1094,114 @@ proc skip_hp_tests {} { return $skip_hp } -global compiler_info -set compiler_info unknown +set compiler_info "unknown" +set gcc_compiled 0 +set hp_cc_compiler 0 +set hp_aCC_compiler 0 +set signed_keyword_not_used 0 + +# Figure out what compiler I am using. +# +# BINFILE is a "compiler information" output file. This implementation +# does not use BINFILE. +# +# ARGS can be empty or "C++". If empty, "C" is assumed. +# +# There are several ways to do this, with various problems. +# +# [ gdb_compile -E $ifile -o $binfile.ci ] +# source $binfile.ci +# +# Single Unix Spec v3 says that "-E -o ..." together are not +# specified. And in fact, the native compiler on hp-ux 11 (among +# others) does not work with "-E -o ...". Most targets used to do +# this, and it mostly worked, because it works with gcc. +# +# [ catch "exec $compiler -E $ifile > $binfile.ci" exec_output ] +# source $binfile.ci +# +# This avoids the problem with -E and -o together. This almost works +# if the build machine is the same as the host machine, which is +# usually true of the targets which are not gcc. But this code does +# not figure which compiler to call, and it always ends up using the C +# compiler. Not good for setting hp_aCC_compiler. Targets +# hppa*-*-hpux* and mips*-*-irix* used to do this. +# +# [ gdb_compile -E $ifile > $binfile.ci ] +# source $binfile.ci +# +# dejagnu target_compile says that it supports output redirection, +# but the code is completely different from the normal path and I +# don't want to sweep the mines from that path. So I didn't even try +# this. +# +# set cppout [ gdb_compile $ifile "" preprocess $args quiet ] +# eval $cppout +# +# I actually do this for all targets now. gdb_compile runs the right +# compiler, and TCL captures the output, and I eval the output. +# +# Unfortunately, expect logs the output of the command as it goes by, +# and dejagnu helpfully prints a second copy of it right afterwards. +# So I turn off expect logging for a moment. +# +# [ gdb_compile $ifile $ciexe_file executable $args ] +# [ remote_exec $ciexe_file ] +# [ source $ci_file.out ] +# +# I could give up on -E and just do this. +# I didn't get desperate enough to try this. +# +# -- chastain 2004-01-06 proc get_compiler_info {binfile args} { - # Create and source the file that provides information about the compiler - # used to compile the test case. - # Compiler_type can be null or c++. If null we assume c. + # For compiler.c and compiler.cc global srcdir - global subdir - # These two come from compiler.c. - global signed_keyword_not_used - global gcc_compiled + + # I am going to play with the log to keep noise out. + global outdir + global tool + + # These come from compiler.c or compiler.cc global compiler_info + global gcc_compiled + global hp_cc_compiler + global hp_aCC_compiler + global signed_keyword_not_used - if {![istarget "hppa*-*-hpux*"] && ![istarget "mips*-*-irix*"]} { - if { [llength $args] > 0 } { - if {$args == "c++"} { - if { [gdb_compile "${srcdir}/lib/compiler.cc" "${binfile}.ci" preprocess {}] != "" } { - perror "Couldn't make ${binfile}.ci file" - return 1; - } - } - } else { - if { [gdb_compile "${srcdir}/lib/compiler.c" "${binfile}.ci" preprocess {}] != "" } { - perror "Couldn't make ${binfile}.ci file" - return 1; - } - } - } else { - if { [llength $args] > 0 } { - if {$args == "c++"} { - if { [eval gdb_preprocess \ - [list "${srcdir}/lib/compiler.cc" "${binfile}.ci"] \ - $args] != "" } { - perror "Couldn't make ${binfile}.ci file" - return 1; - } - } - } elseif { $args != "f77" } { - if { [eval gdb_preprocess \ - [list "${srcdir}/lib/compiler.c" "${binfile}.ci"] \ - $args] != "" } { - perror "Couldn't make ${binfile}.ci file" - return 1; - } - } + # Choose which file to preprocess. + set ifile "${srcdir}/lib/compiler.c" + if { [llength $args] > 0 && [lindex $args 0] == "c++" } { + set ifile "${srcdir}/lib/compiler.cc" } - - uplevel \#0 { set gcc_compiled 0 } - if { [llength $args] == 0 || $args != "f77" } { - source ${binfile}.ci + # Run $ifile through the right preprocessor. + # Toggle gdb.log to keep the compiler output out of the log. + log_file + set cppout [ gdb_compile "${ifile}" "" preprocess [list "$args" quiet] ] + log_file -a "$outdir/$tool.log" + + # Source the output. + foreach cppline [ split "$cppout" "\n" ] { + if { ! [ regexp "^#" "$cppline" ] } { + if { ! [ regexp "^\[\n\r\t \]*$" "$cppline" ] } { + verbose "get_compiler_info: $cppline" 2 + eval "$cppline" + } + } } + verbose -log "get_compiler_info: $compiler_info" # Most compilers will evaluate comparisons and other boolean # operations to 0 or 1. uplevel \#0 { set true 1 } uplevel \#0 { set false 0 } - uplevel \#0 { set hp_cc_compiler 0 } - uplevel \#0 { set hp_aCC_compiler 0 } - uplevel \#0 { set hp_f77_compiler 0 } - uplevel \#0 { set hp_f90_compiler 0 } - if { !$gcc_compiled && [istarget "hppa*-*-hpux*"] } { - # Check for the HP compilers - set compiler [lindex [split [get_compiler $args] " "] 0] - catch "exec what $compiler" output - if [regexp ".*HP aC\\+\\+.*" $output] { - uplevel \#0 { set hp_aCC_compiler 1 } - # Use of aCC results in boolean results being displayed as - # "true" or "false" - uplevel \#0 { set true true } - uplevel \#0 { set false false } - } elseif [regexp ".*HP C Compiler.*" $output] { - uplevel \#0 { set hp_cc_compiler 1 } - } elseif [regexp ".*HP-UX f77.*" $output] { - uplevel \#0 { set hp_f77_compiler 1 } - } elseif [regexp ".*HP-UX f90.*" $output] { - uplevel \#0 { set hp_f90_compiler 1 } - } + # Use of aCC results in boolean results being displayed as + # "true" or "false" + if { $hp_aCC_compiler } { + uplevel \#0 { set true true } + uplevel \#0 { set false false } } return 0; @@ -1184,85 +1212,6 @@ proc test_compiler_info { compiler } { return [string match $compiler $compiler_info] } -proc get_compiler {args} { - global CC CC_FOR_TARGET CXX CXX_FOR_TARGET F77_FOR_TARGET - - if { [llength $args] == 0 - || ([llength $args] == 1 && [lindex $args 0] == "") } { - set which_compiler "c" - } else { - if { $args =="c++" } { - set which_compiler "c++" - } elseif { $args =="f77" } { - set which_compiler "f77" - } else { - perror "Unknown compiler type supplied to gdb_preprocess" - return "" - } - } - - if [info exists CC_FOR_TARGET] { - if {$which_compiler == "c"} { - set compiler $CC_FOR_TARGET - } - } - - if [info exists CXX_FOR_TARGET] { - if {$which_compiler == "c++"} { - set compiler $CXX_FOR_TARGET - } - } - - if [info exists F77_FOR_TARGET] { - if {$which_compiler == "f77"} { - set compiler $F77_FOR_TARGET - } - } - - if { ![info exists compiler] } { - if { $which_compiler == "c" } { - if {[info exists CC]} { - set compiler $CC - } - } - if { $which_compiler == "c++" } { - if {[info exists CXX]} { - set compiler $CXX - } - } - if {![info exists compiler]} { - set compiler [board_info [target_info name] compiler]; - if { $compiler == "" } { - perror "get_compiler: No compiler found" - return "" - } - } - } - - return $compiler -} - -proc gdb_preprocess {source dest args} { - set compiler [get_compiler "$args"] - if { $compiler == "" } { - return 1 - } - - set cmdline "$compiler -E $source > $dest" - - verbose "Invoking $compiler -E $source > $dest" - verbose -log "Executing on local host: $cmdline" 2 - set status [catch "exec ${cmdline}" exec_output] - - set result [prune_warnings $exec_output] - regsub "\[\r\n\]*$" "$result" "" result; - regsub "^\[\r\n\]*" "$result" "" result; - if { $result != "" } { - clone_output "gdb compile failed, $result" - } - return $result; -} - set gdb_wrapper_initialized 0 proc gdb_wrapper_init { args } { |