From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 127202 invoked by alias); 6 Jun 2016 15:25:53 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 127191 invoked by uid 89); 6 Jun 2016 15:25:52 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.6 required=5.0 tests=BAYES_00,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,SPF_PASS autolearn=ham version=3.3.2 spammy= X-HELO: mail-qt0-f174.google.com Received: from mail-qt0-f174.google.com (HELO mail-qt0-f174.google.com) (209.85.216.174) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Mon, 06 Jun 2016 15:25:42 +0000 Received: by mail-qt0-f174.google.com with SMTP id 9so9281347qtg.2 for ; Mon, 06 Jun 2016 08:25:41 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:sender:subject:to:references:cc:from:message-id :date:user-agent:mime-version:in-reply-to; bh=mpe8S2ay2TnHokv38PU+kbk2ITIZCjS/idkdM7eEI+8=; b=k2pFJp7GLb56Axxm8nWMCCPDPucKzZTSQ7wjkhhTMvrj+dqoEfVxkr9wI5fX9mVRDQ JSKpoolc3+nu3dF0F1jWgHoVYLhyP4tuIls+IQ0W5eZHWJ0arKctfHH5C+L8oHNBcD1h EVOZwIOrdX7FL/KjMI2SSdVEfdFAAUeuqPybirlRegrhoTmtcktmB2uss9/kqQZZCdC8 9g9UxiOTRlzJJt5Gkw/8yqMHiQmRPs/AC3x+wr0WdlFlPBrg76+33kroAZA3xe4RZkii 98C54s38kLeT0FeJ6VjaSF5Jt7p3PoPdtvJCg5KvxUmlKSRzTRcgp6iCx7Tf9CuFzg+y PbjQ== X-Gm-Message-State: ALyK8tLaX9bqR6zihcV+NAqcplvPgFRPHKtyYQ3Hzjl3EEkmK/I8d+rn/QS95q+bNG1iIQ== X-Received: by 10.200.40.197 with SMTP id j5mr6552908qtj.14.1465226740057; Mon, 06 Jun 2016 08:25:40 -0700 (PDT) Received: from ?IPv6:2601:181:c003:1930:a2a8:cdff:fe3e:b48? ([2601:181:c003:1930:a2a8:cdff:fe3e:b48]) by smtp.googlemail.com with ESMTPSA id k61sm5846026qtd.5.2016.06.06.08.25.38 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 06 Jun 2016 08:25:39 -0700 (PDT) Subject: Re: [PATCH v2] gcov: Runtime configurable destination output To: Aaron Conole , "H.J. Lu" References: <1456350732-8272-1-git-send-email-aconole@bytheb.org> <8040ea19-7c4f-03ab-ba90-d82b35abcb32@acm.org> Cc: GCC Patches , Jan Hubicka From: Nathan Sidwell Message-ID: <23769f97-e215-2afd-00fb-7bc75aa1d083@acm.org> Date: Mon, 06 Jun 2016 15:25:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.1.0 MIME-Version: 1.0 In-Reply-To: Content-Type: multipart/mixed; boundary="------------05DCAA2E79CD2C37D936F9E5" X-SW-Source: 2016-06/txt/msg00396.txt.bz2 This is a multi-part message in MIME format. --------------05DCAA2E79CD2C37D936F9E5 Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit Content-length: 94 I applied this patch. Aaron's patch, AFAICT, would repeatedly fopen the error file. nathan --------------05DCAA2E79CD2C37D936F9E5 Content-Type: text/x-patch; name="gcov-prof.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="gcov-prof.patch" Content-length: 2128 2016-06-05 Aaron Conole Nathan Sidwell PR libgcc/71400 * libgcov-driver-system.c (__gcov_error_file): Disable if IN_GCOV_TOOL. (get_gcov_error_file): Check __gcov_error_file before trying to initialize it. (gcov_error): Always use get_gcov_error_file. Index: libgcov-driver-system.c =================================================================== --- libgcov-driver-system.c (revision 237131) +++ libgcov-driver-system.c (working copy) @@ -23,31 +23,32 @@ a copy of the GCC Runtime Library Except see the files COPYING3 and COPYING.RUNTIME respectively. If not, see . */ +#if !IN_GCOV_TOOL /* Configured via the GCOV_ERROR_FILE environment variable; it will either be stderr, or a file of the user's choosing. Non-static to prevent multiple gcov-aware shared objects from instantiating their own copies. */ FILE *__gcov_error_file = NULL; +#endif /* A utility function to populate the __gcov_error_file pointer. This should NOT be called outside of the gcov system driver code. */ static FILE * -get_gcov_error_file(void) +get_gcov_error_file (void) { -#if !IN_GCOV_TOOL +#if IN_GCOV_TOOL return stderr; #else - char *gcov_error_filename = getenv ("GCOV_ERROR_FILE"); - - if (gcov_error_filename) + if (!__gcov_error_file) { - FILE *openfile = fopen (gcov_error_filename, "a"); - if (openfile) - __gcov_error_file = openfile; + const char *gcov_error_filename = getenv ("GCOV_ERROR_FILE"); + + if (gcov_error_filename) + __gcov_error_file = fopen (gcov_error_filename, "a"); + if (!__gcov_error_file) + __gcov_error_file = stderr; } - if (!__gcov_error_file) - __gcov_error_file = stderr; return __gcov_error_file; #endif } @@ -60,11 +61,8 @@ gcov_error (const char *fmt, ...) int ret; va_list argp; - if (!__gcov_error_file) - __gcov_error_file = get_gcov_error_file (); - va_start (argp, fmt); - ret = vfprintf (__gcov_error_file, fmt, argp); + ret = vfprintf (get_gcov_error_file (), fmt, argp); va_end (argp); return ret; } --------------05DCAA2E79CD2C37D936F9E5--