From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 8929 invoked by alias); 5 Feb 2004 23:13:47 -0000 Mailing-List: contact gdb-patches-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sources.redhat.com Received: (qmail 8869 invoked from network); 5 Feb 2004 23:13:45 -0000 Received: from unknown (HELO granger.mail.mindspring.net) (207.69.200.148) by sources.redhat.com with SMTP; 5 Feb 2004 23:13:45 -0000 Received: from user-119a90a.biz.mindspring.com ([66.149.36.10] helo=berman.michael-chastain.com) by granger.mail.mindspring.net with esmtp (Exim 3.33 #1) id 1Aosgn-00033g-00; Thu, 05 Feb 2004 18:13:41 -0500 Received: by berman.michael-chastain.com (Postfix, from userid 502) id 9529A4B364; Thu, 5 Feb 2004 18:13:51 -0500 (EST) To: cagney@gnu.org, mec.gnu@mindspring.com Subject: Re: more robust get_compiler_info Cc: brobecker@gnat.com, gdb-patches@sources.redhat.com Message-Id: <20040205231351.9529A4B364@berman.michael-chastain.com> Date: Thu, 05 Feb 2004 23:13:00 -0000 From: mec.gnu@mindspring.com (Michael Elizabeth Chastain) X-SW-Source: 2004-02/txt/msg00112.txt.bz2 ac> ... can instead just compiler_info be set. Sounds good to me. I will give it a whirl. Here is the new patch, not tested yet, not even a ChangeLog entry. Michael C === Index: lib/compiler.c =================================================================== RCS file: /cvs/src/src/gdb/testsuite/lib/compiler.c,v retrieving revision 1.3 diff -c -3 -p -r1.3 compiler.c *** lib/compiler.c 24 Jan 2004 21:59:03 -0000 1.3 --- lib/compiler.c 5 Feb 2004 23:11:00 -0000 *************** *** 34,60 **** TODO: purge signed_keyword_not_used. */ ! set compiler_info "" #if defined (__GNUC__) set compiler_info [join {gcc __GNUC__ __GNUC_MINOR__ } -] - set gcc_compiled __GNUC__ - #else - set gcc_compiled 0 #endif #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 */ --- 34,51 ---- TODO: purge signed_keyword_not_used. */ ! set compiler_info "unknown" #if defined (__GNUC__) set compiler_info [join {gcc __GNUC__ __GNUC_MINOR__ } -] #endif #if defined (__HP_cc) set compiler_info [join {hpcc __HP_cc} -] #endif #if defined (__HP_aCC) set compiler_info [join {hpacc __HP_aCC} -] #endif /* gdb.base/whatis.exp still uses this */ Index: lib/compiler.cc =================================================================== RCS file: /cvs/src/src/gdb/testsuite/lib/compiler.cc,v retrieving revision 1.5 diff -c -3 -p -r1.5 compiler.cc *** lib/compiler.cc 24 Jan 2004 21:59:03 -0000 1.5 --- lib/compiler.cc 5 Feb 2004 23:11:00 -0000 *************** *** 22,48 **** /* 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". */ ! set compiler_info "" #if defined (__GNUC__) set compiler_info [join {gcc __GNUC__ __GNUC_MINOR__ } -] - set gcc_compiled __GNUC__ - #else - set gcc_compiled 0 #endif #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 */ --- 22,39 ---- /* 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". */ ! set compiler_info "unknown" #if defined (__GNUC__) set compiler_info [join {gcc __GNUC__ __GNUC_MINOR__ } -] #endif #if defined (__HP_cc) set compiler_info [join {hpcc __HP_cc} -] #endif #if defined (__HP_aCC) set compiler_info [join {hpacc __HP_aCC} -] #endif /* gdb.base/whatis.exp still uses this */ Index: lib/gdb.exp =================================================================== RCS file: /cvs/src/src/gdb/testsuite/lib/gdb.exp,v retrieving revision 1.45 diff -c -3 -p -r1.45 gdb.exp *** lib/gdb.exp 2 Feb 2004 21:14:33 -0000 1.45 --- lib/gdb.exp 5 Feb 2004 23:11:00 -0000 *************** proc get_compiler_info {binfile args} { *** 1169,1178 **** # 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 # Choose which file to preprocess. set ifile "${srcdir}/lib/compiler.c" --- 1169,1180 ---- # These come from compiler.c or compiler.cc global compiler_info + global signed_keyword_not_used + + # Legacy global data symbols. global gcc_compiled global hp_cc_compiler global hp_aCC_compiler # Choose which file to preprocess. set ifile "${srcdir}/lib/compiler.c" *************** proc get_compiler_info {binfile args} { *** 1186,1200 **** 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 --- 1188,1229 ---- set cppout [ gdb_compile "${ifile}" "" preprocess [list "$args" quiet] ] log_file -a "$outdir/$tool.log" ! # Eval the output. ! set unknown 0 foreach cppline [ split "$cppout" "\n" ] { ! if { [ regexp "^#" "$cppline" ] } { ! # line marker ! } elseif { [ regexp "^\[\n\r\t \]*$" "$cppline" ] } { ! # blank line ! } elseif { [ regexp "^\[\n\r\t \]*set\[\n\r\t \]" "$cppline" ] } { ! # eval this line ! verbose "get_compiler_info: $cppline" 2 ! eval "$cppline" ! } else { ! # unknown line ! verbose -log "get_compiler_info: $cppline" ! set unknown 1 } } + + # Reset to unknown compiler if any diagnostics happened. + if { $unknown } { + set compiler_info "unknown" + set signed_keyword_not_used 0 + } + + # Set the legacy symbols. + set gcc_compiled 0 + set hp_cc_compiler 0 + set hp_aCC_compiler 0 + if { [regexp "^gcc-1-" "$compiler_info" ] } { set gcc_compiled 1 } + if { [regexp "^gcc-2-" "$compiler_info" ] } { set gcc_compiled 2 } + if { [regexp "^gcc-3-" "$compiler_info" ] } { set gcc_compiled 3 } + if { [regexp "^gcc-4-" "$compiler_info" ] } { set gcc_compiled 4 } + if { [regexp "^hpcc-" "$compiler_info" ] } { set hp_cc_compiler 1 } + if { [regexp "^hpacc-" "$compiler_info" ] } { set hp_aCC_compiler 1 } + + # Log what happened. verbose -log "get_compiler_info: $compiler_info" # Most compilers will evaluate comparisons and other boolean