This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH v2] gcov: Runtime configurable destination output
- From: Nathan Sidwell <nathan at acm dot org>
- To: Aaron Conole <aconole at redhat dot com>, "H.J. Lu" <hjl dot tools at gmail dot com>
- Cc: GCC Patches <gcc-patches at gcc dot gnu dot org>, Jan Hubicka <hubicka at ucw dot cz>
- Date: Mon, 6 Jun 2016 11:25:37 -0400
- Subject: Re: [PATCH v2] gcov: Runtime configurable destination output
- Authentication-results: sourceware.org; auth=none
- References: <1456350732-8272-1-git-send-email-aconole at bytheb dot org> <df966285-a4fe-34f8-6643-92d1d4c37048 at acm dot org> <f7th9dt7uxw dot fsf at redhat dot com> <8040ea19-7c4f-03ab-ba90-d82b35abcb32 at acm dot org> <f7t1t4s63na dot fsf at redhat dot com> <CAMe9rOrJJZzj_QuohGW1UOfO0Lj2Cyp-1-jAdceR=qp1qe37aw at mail dot gmail dot com> <f7ty46l9mqp dot fsf at redhat dot com>
I applied this patch. Aaron's patch, AFAICT, would repeatedly fopen the error file.
nathan
2016-06-05 Aaron Conole <aconole@redhat.com>
Nathan Sidwell <nathan@acm.org>
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
<http://www.gnu.org/licenses/>. */
+#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;
}