From patchwork Wed Nov 7 13:50:54 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rainer Orth X-Patchwork-Id: 197673 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) by ozlabs.org (Postfix) with SMTP id EB1162C00A3 for ; Thu, 8 Nov 2012 00:51:10 +1100 (EST) Comment: DKIM? See http://www.dkim.org DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=gcc.gnu.org; s=default; x=1352901071; h=Comment: DomainKey-Signature:Received:Received:Received:Received:Received: Received:Received:From:To:Cc:Subject:References:Date:In-Reply-To: Message-ID:User-Agent:MIME-Version:Content-Type:Mailing-List: Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:Sender:Delivered-To; bh=txlNGf/DzG82QdQCE0Wwmwa7xfg=; b=f2RwnPkAnJbQUXZuHCpp/6Cz4lKtj5ovIN5OUeK3dhVGlYJ+yugV0H+RYDIksX bohjwvgQzz+Q5efBGZWSXKeKYfRD9hChTYV57P1UIqQlZs8oGqZEg458TUGI6jgv 4ly6rClWN/H7GyJSNUf3hPupmWwutSLGV/Pw/Le/z5kqI= Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=default; d=gcc.gnu.org; h=Received:Received:X-SWARE-Spam-Status:X-Spam-Check-By:Received:Received:Received:Received:Received:From:To:Cc:Subject:References:Date:In-Reply-To:Message-ID:User-Agent:MIME-Version:Content-Type:X-IsSubscribed:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=ol8LgCLuiCJeZPsLk7NHUtG2NyxihH1Mzzzetx0Jj659YHjRqud+D0P/IQyo00 exn6gVO50Uoa+t/ZH+2aCIOo0i6lPrczhTGJq8aKS3a2roou6hVmiy4+0nxzwmNH /t5X6tFNYg6J3RKn0tCyfloqr0umC1Q5RoZRhxqw8nSeM=; Received: (qmail 15058 invoked by alias); 7 Nov 2012 13:51:05 -0000 Received: (qmail 15048 invoked by uid 22791); 7 Nov 2012 13:51:04 -0000 X-SWARE-Spam-Status: No, hits=-2.2 required=5.0 tests=AWL, BAYES_00, RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from snape.CeBiTec.Uni-Bielefeld.DE (HELO smtp-relay.CeBiTec.Uni-Bielefeld.DE) (129.70.160.84) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 07 Nov 2012 13:50:59 +0000 Received: from localhost (localhost.CeBiTec.Uni-Bielefeld.DE [127.0.0.1]) by smtp-relay.CeBiTec.Uni-Bielefeld.DE (Postfix) with ESMTP id 1EC8319; Wed, 7 Nov 2012 14:50:58 +0100 (CET) Received: from smtp-relay.CeBiTec.Uni-Bielefeld.DE ([127.0.0.1]) by localhost (malfoy.CeBiTec.Uni-Bielefeld.DE [127.0.0.1]) (amavisd-new, port 10024) with LMTP id X99R1GRSMmP4; Wed, 7 Nov 2012 14:50:55 +0100 (CET) Received: from manam.CeBiTec.Uni-Bielefeld.DE (manam.CeBiTec.Uni-Bielefeld.DE [129.70.161.120]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp-relay.CeBiTec.Uni-Bielefeld.DE (Postfix) with ESMTPS id 5C92D16; Wed, 7 Nov 2012 14:50:55 +0100 (CET) Received: (from ro@localhost) by manam.CeBiTec.Uni-Bielefeld.DE (8.14.5+Sun/8.14.5/Submit) id qA7Dos1i008335; Wed, 7 Nov 2012 14:50:54 +0100 (MET) From: Rainer Orth To: Gerald Pfeifer Cc: Ian Lance Taylor , gcc-patches@gcc.gnu.org Subject: Re: [libbacktrace] Use getexecname() on Solaris References: Date: Wed, 07 Nov 2012 14:50:54 +0100 In-Reply-To: (Gerald Pfeifer's message of "Thu, 11 Oct 2012 14:04:10 +0200 (CEST)") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.1 (usg-unix-v) MIME-Version: 1.0 X-IsSubscribed: yes Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Gerald Pfeifer writes: > Just a small note, in the following > > +#ifdef __FreeBSD__ > +# define DEFAULT_PROCESS_FILENAME "/proc/curproc/file" > +#elif defined(HAVE_GETEXECNAME) > +# define DEFAULT_PROCESS_FILENAME getexecname () > +#else > +# define DEFAULT_PROCESS_FILENAME "/proc/self/exe" > +#endif > > would it make sense to have the feature test (HAVE_GETEXECNAME) before > the OS test (__FreeBSD__), so that when/if the OS implements the feature > in newer versions that takes precedence? Good point. I've incorporated this into my patch and regularly include it in my *-*-solaris2.{9, 10, 11} and x86_64-unknown-linux-gnu bootstraps. Ok for mainline? Rainer 2012-10-05 Rainer Orth Gerald Pfeifer libbacktrace: * configure.ac: Check for getexecname. * configure: Regenerate. * config.h.in: Regenerate. * internal.h (DEFAULT_PROCESS_FILENAME): Define. * fileline.c (fileline_initialize): Use it. * print.c (error_callback): Likewise. Include . # HG changeset patch # Parent a6a174227cae12381edf325b21adc905e8fa50e6 Use getexecname() on Solaris diff --git a/libbacktrace/configure.ac b/libbacktrace/configure.ac --- a/libbacktrace/configure.ac +++ b/libbacktrace/configure.ac @@ -289,6 +289,19 @@ fi AC_CHECK_DECLS(strnlen) +# Check for getexecname function. +if test -n "${with_target_subdir}"; then + case "${host}" in + *-*-solaris2*) have_getexecname=yes ;; + *) have_getexecname=no ;; + esac +else + AC_CHECK_FUNC(getexecname, [have_getexecname=yes], [have_getexecname=no]) +fi +if test "$have_getexecname" = "yes"; then + AC_DEFINE(HAVE_GETEXECNAME, 1, [Define if getexecname is available.]) +fi + AC_CACHE_CHECK([whether tests can run], [libbacktrace_cv_sys_native], [AC_RUN_IFELSE([AC_LANG_PROGRAM([], [return 0;])], diff --git a/libbacktrace/fileline.c b/libbacktrace/fileline.c --- a/libbacktrace/fileline.c +++ b/libbacktrace/fileline.c @@ -82,7 +82,8 @@ fileline_initialize (struct backtrace_st if (state->filename != NULL) descriptor = backtrace_open (state->filename, error_callback, data, NULL); else - descriptor = backtrace_open ("/proc/self/exe", error_callback, data, NULL); + descriptor = backtrace_open (DEFAULT_PROCESS_FILENAME, error_callback, + data, NULL); if (descriptor < 0) failed = 1; diff --git a/libbacktrace/internal.h b/libbacktrace/internal.h --- a/libbacktrace/internal.h +++ b/libbacktrace/internal.h @@ -56,6 +56,14 @@ POSSIBILITY OF SUCH DAMAGE. */ # endif #endif +#ifdef HAVE_GETEXECNAME +# define DEFAULT_PROCESS_FILENAME getexecname () +#elif defined(__FreeBSD__) +# define DEFAULT_PROCESS_FILENAME "/proc/curproc/file" +#else +# define DEFAULT_PROCESS_FILENAME "/proc/self/exe" +#endif + #ifndef HAVE_SYNC_FUNCTIONS /* Define out the sync functions. These should never be called if diff --git a/libbacktrace/print.c b/libbacktrace/print.c --- a/libbacktrace/print.c +++ b/libbacktrace/print.c @@ -35,6 +35,7 @@ POSSIBILITY OF SUCH DAMAGE. */ #include #include #include +#include #include "backtrace.h" #include "internal.h" @@ -73,7 +74,7 @@ error_callback (void *data, const char * name = pdata->state->filename; if (name == NULL) - name = "/proc/self/exe"; + name = DEFAULT_PROCESS_FILENAME; fprintf (stderr, "%s: libbacktrace: %s", name, msg); if (errnum > 0) fprintf (stderr, ": %s", strerror (errnum));