From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 12199 invoked by alias); 14 Jun 2004 13:44:52 -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 12187 invoked from network); 14 Jun 2004 13:44:50 -0000 Received: from unknown (HELO mx1.redhat.com) (66.187.233.31) by sourceware.org with SMTP; 14 Jun 2004 13:44:50 -0000 Received: from int-mx1.corp.redhat.com (int-mx1.corp.redhat.com [172.16.52.254]) by mx1.redhat.com (8.12.10/8.12.10) with ESMTP id i5EDioi7001415 for ; Mon, 14 Jun 2004 09:44:50 -0400 Received: from localhost.redhat.com (porkchop.devel.redhat.com [172.16.58.2]) by int-mx1.corp.redhat.com (8.11.6/8.11.6) with ESMTP id i5EDim031974; Mon, 14 Jun 2004 09:44:49 -0400 Received: from gnu.org (localhost [127.0.0.1]) by localhost.redhat.com (Postfix) with ESMTP id 1125D2B9D; Mon, 14 Jun 2004 09:44:36 -0400 (EDT) Message-ID: <40CDABC3.30803@gnu.org> Date: Mon, 14 Jun 2004 13:44:00 -0000 From: Andrew Cagney User-Agent: Mozilla/5.0 (X11; U; NetBSD macppc; en-GB; rv:1.4.1) Gecko/20040217 MIME-Version: 1.0 To: Michael Elizabeth Chastain Cc: gdb-patches@sources.redhat.com Subject: Re: [rfa/testsuite/lib/ping] get_compiler_info: tighten up References: <20040611212534.DBBF04B104@berman.michael-chastain.com> In-Reply-To: <20040611212534.DBBF04B104@berman.michael-chastain.com> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-SW-Source: 2004-06/txt/msg00310.txt.bz2 > This patch has been pending for four months. Time for another go-round. (I thought it was on hold pending further testing, oops) > This patch does two things to get_compiler_info. > > First, I tweaked the "eval" mechanism to eval only the "set lines". > This stops get_compiler_info from eval'ing random compiler diagnostics. > This fixes a problem reported by Joel B. > > Second, as requested by Andrew C, this patch changes the implementation > of gcc_compiled, hp_cc_compiler, and hp_aCC_compiler to be more local > to gdb.exp, with no trace of these symbols in compiler.c and > compiler.cc. > > Testing: I tested this on native i686-pc-linux-gnu with gcc 2.95.3 > and gcc 3.3.3. I also tested on native hppa2.0w-hp-hpux11.11 > with HP ansi-c and HP aCC. Joel B also tested an earlier version of > this and says that it works for him. Just so that there's no transition confusion here, yes, ok by me to commit :-) Andrew > Michael C > > 2004-06-11 Michael Chastain > > * lib/compiler.c: Remove gcc_compiled, hp_cc_compiler, > hp_aCC_compiler. > * lib/compiler.cc: Likewise. > * lib/gdb.exp (get_compiler_info): Eval lines only if they are > 'set' commands. Log diagnostics for other lines. Set > gcc_compiled, hp_cc_compiler, and hp_aCC_compiler. > > Index: lib/compiler.c > =================================================================== > RCS file: /cvs/src/src/gdb/testsuite/lib/compiler.c,v > retrieving revision 1.4 > diff -c -3 -p -r1.4 compiler.c > *** lib/compiler.c 10 Jun 2004 21:38:03 -0000 1.4 > --- lib/compiler.c 11 Jun 2004 18:39:31 -0000 > *************** > *** 34,40 **** > > TODO: purge signed_keyword_not_used. */ > > ! set compiler_info "" > > #if defined (__GNUC__) > #if defined (__GNUC_PATCHLEVEL__) > --- 34,40 ---- > > TODO: purge signed_keyword_not_used. */ > > ! set compiler_info "unknown" > > #if defined (__GNUC__) > #if defined (__GNUC_PATCHLEVEL__) > *************** set compiler_info [join {gcc __GNUC__ __ > *** 43,65 **** > #else > set compiler_info [join {gcc __GNUC__ __GNUC_MINOR__ "unknown"} -] > #endif > - 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 */ > --- 43,56 ---- > Index: lib/compiler.cc > =================================================================== > RCS file: /cvs/src/src/gdb/testsuite/lib/compiler.cc,v > retrieving revision 1.6 > diff -c -3 -p -r1.6 compiler.cc > *** lib/compiler.cc 10 Jun 2004 21:38:03 -0000 1.6 > --- lib/compiler.cc 11 Jun 2004 18:39:31 -0000 > *************** > *** 22,28 **** > /* 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__) > #if defined (__GNUC_PATCHLEVEL__) > --- 22,28 ---- > /* 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__) > #if defined (__GNUC_PATCHLEVEL__) > *************** set compiler_info [join {gcc __GNUC__ __ > *** 31,53 **** > #else > set compiler_info [join {gcc __GNUC__ __GNUC_MINOR__ "unknown"} -] > #endif > - 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 */ > --- 31,44 ---- > Index: lib/gdb.exp > =================================================================== > RCS file: /cvs/src/src/gdb/testsuite/lib/gdb.exp,v > retrieving revision 1.51 > diff -c -3 -p -r1.51 gdb.exp > *** lib/gdb.exp 21 May 2004 17:26:57 -0000 1.51 > --- lib/gdb.exp 11 Jun 2004 18:39:32 -0000 > *************** proc get_compiler_info {binfile args} { > *** 1190,1199 **** > > # 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" > --- 1190,1201 ---- > > # 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} { > *** 1207,1221 **** > 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 > --- 1209,1251 ---- > 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 "^gcc-5-" "$compiler_info" ] } { set gcc_compiled 5 } > + 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 >