From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 13724 invoked by alias); 20 Aug 2002 21:34:44 -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 13717 invoked from network); 20 Aug 2002 21:34:43 -0000 Received: from unknown (HELO zenia.red-bean.com) (66.244.67.22) by sources.redhat.com with SMTP; 20 Aug 2002 21:34:43 -0000 Received: (from jimb@localhost) by zenia.red-bean.com (8.11.6/8.11.6) id g7KLO2k08116; Tue, 20 Aug 2002 16:24:02 -0500 To: Fernando Nasser , Michael Snyder CC: gdb-patches@sources.redhat.com Subject: [Jim Blandy ] RFA: abstract out thread compilation code From: Jim Blandy Date: Tue, 20 Aug 2002 14:34:00 -0000 Message-ID: User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.2.90 MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-SW-Source: 2002-08/txt/msg00618.txt.bz2 --=-=-= Content-length: 24 Any comments on this? --=-=-= Content-Type: message/rfc822 Content-Disposition: inline Content-length: 6178 X-From-Line: jimb@redhat.com Thu Jun 13 12:42:06 2002 Received: from int-mx1.corp.redhat.com (int-mx1.corp.redhat.com [172.16.52.254]) by runyon.cygnus.com (8.8.7-cygnus/8.8.7) with ESMTP id KAA09122 for ; Thu, 13 Jun 2002 10:42:33 -0700 (PDT) Received: from mx1.redhat.com (mx1.redhat.com [172.16.48.31]) by int-mx1.corp.redhat.com (8.11.6/8.11.6) with SMTP id g5DHgW326577 for ; Thu, 13 Jun 2002 13:42:32 -0400 Received: from sources.redhat.com (sources.redhat.com [209.249.29.67]) by mx1.redhat.com (8.11.6/8.11.6) with SMTP id g5DHY5913033 for ; Thu, 13 Jun 2002 13:34:05 -0400 Received: (qmail 30247 invoked by alias); 13 Jun 2002 17:42:11 -0000 Received: (qmail 30230 invoked from network); 13 Jun 2002 17:42:07 -0000 Received: from unknown (HELO zwingli.cygnus.com) (208.245.165.35) by sources.redhat.com with SMTP; 13 Jun 2002 17:42:07 -0000 Received: by zwingli.cygnus.com (Postfix, from userid 442) id DCA255EA11; Thu, 13 Jun 2002 12:42:06 -0500 (EST) Mailing-List: contact gdb-patches-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sources.redhat.com Delivered-To: mailing list gdb-patches@sources.redhat.com From: Jim Blandy To: gdb-patches@sources.redhat.com Subject: RFA: abstract out thread compilation code Gnus-Warning: This is a duplicate of message <20020613174206.DCA255EA11@zwingli.cygnus.com> Message-Id: <20020613174206.DCA255EA11@zwingli.cygnus.com> Date: Thu, 13 Jun 2002 12:42:06 -0500 (EST) X-Content-Length: 4115 Status: Content-length: 4116 Lines: 128 Xref: zwingli.cygnus.com mail.gdb.patches:16880 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii 2002-06-13 Jim Blandy * gdb.threads/pthreads.exp: Move the portable thread compilation code into a function in lib/gdb.exp, and call that from here. * lib/gdb.exp (gdb_compile_pthreads): New function. Index: gdb/testsuite/gdb.threads/pthreads.exp =================================================================== RCS file: /cvs/src/src/gdb/testsuite/gdb.threads/pthreads.exp,v retrieving revision 1.7 diff -c -r1.7 pthreads.exp *** gdb/testsuite/gdb.threads/pthreads.exp 1 Oct 2001 20:36:48 -0000 1.7 --- gdb/testsuite/gdb.threads/pthreads.exp 13 Jun 2002 17:39:46 -0000 *************** *** 39,80 **** # carriage return) set horiz "\[^\n\r\]*" - set built_binfile 0 if [istarget "*-*-linux"] then { set target_cflags "-D_MIT_POSIX_THREADS" } else { set target_cflags "" } ! set why_msg "unrecognized error" ! foreach lib {-lpthreads -lpthread -lthread} { ! set options "debug" ! lappend options "incdir=${objdir}/${subdir}" ! lappend options "libs=$lib" ! set ccout [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable $options] ! switch -regexp -- $ccout { ! ".*no posix threads support.*" { ! set why_msg "missing threads include file" ! break ! } ! ".*cannot open -lpthread.*" { ! set why_msg "missing runtime threads library" ! } ! ".*Can't find library for -lpthread.*" { ! set why_msg "missing runtime threads library" ! } ! {^$} { ! pass "successfully compiled posix threads test case" ! set built_binfile 1 ! break ! } ! } ! } ! if {$built_binfile == "0"} { ! unsupported "Couldn't compile ${srcfile}, ${why_msg}" ! return -1 } - # Now we can proceed with the real testing. # Start with a fresh gdb. --- 39,54 ---- # carriage return) set horiz "\[^\n\r\]*" if [istarget "*-*-linux"] then { set target_cflags "-D_MIT_POSIX_THREADS" } else { set target_cflags "" } ! ! if {[gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable [list debug "incdir=${objdir}/${subdir}"]] != "" } { ! gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." } # Start with a fresh gdb. Index: gdb/testsuite/lib/gdb.exp =================================================================== RCS file: /cvs/src/src/gdb/testsuite/lib/gdb.exp,v retrieving revision 1.20 diff -c -r1.20 gdb.exp *** gdb/testsuite/lib/gdb.exp 11 Jun 2002 20:37:05 -0000 1.20 --- gdb/testsuite/lib/gdb.exp 13 Jun 2002 17:39:46 -0000 *************** *** 1171,1176 **** --- 1171,1212 ---- return $result; } + + # This is just like gdb_compile, above, except that it tries compiling + # against several different thread libraries, to see which one this + # system has. + proc gdb_compile_pthreads {source dest type options} { + set build_binfile 0 + set why_msg "unrecognized error" + foreach lib {-lpthreads -lpthread -lthread} { + # This kind of wipes out whatever libs the caller may have + # set. Or maybe theirs will override ours. How infelicitous. + set options_with_lib [concat $options [list libs=$lib]] + set ccout [gdb_compile $source $dest $type $options_with_lib] + switch -regexp -- $ccout { + ".*no posix threads support.*" { + set why_msg "missing threads include file" + break + } + ".*cannot open -lpthread.*" { + set why_msg "missing runtime threads library" + } + ".*Can't find library for -lpthread.*" { + set why_msg "missing runtime threads library" + } + {^$} { + pass "successfully compiled posix threads test case" + set built_binfile 1 + break + } + } + } + if {$built_binfile == "0"} { + unsupported "Couldn't compile $source: ${why_msg}" + return -1 + } + } + proc send_gdb { string } { global suppress_flag; if { $suppress_flag } { --=-=-=--