]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
libgcov: report about a different timestamp (PR gcov-profile/85759).
authorMartin Liska <mliska@suse.cz>
Tue, 29 May 2018 12:11:21 +0000 (14:11 +0200)
committerMartin Liska <marxin@gcc.gnu.org>
Tue, 29 May 2018 12:11:21 +0000 (12:11 +0000)
2018-05-29  Martin Liska  <mliska@suse.cz>

        PR gcov-profile/85759
* doc/gcov.texi: Document GCOV_ERROR_FILE and GCOV_EXIT_AT_ERROR
env variables.
2018-05-29  Martin Liska  <mliska@suse.cz>

        PR gcov-profile/85759
* libgcov-driver-system.c (gcov_error): Introduce usage of
        GCOV_EXIT_AT_ERROR env. variable.
* libgcov-driver.c (merge_one_data): Print error that we
        overwrite a gcov file with a different timestamp.

From-SVN: r260895

gcc/ChangeLog
gcc/doc/gcov.texi
libgcc/ChangeLog
libgcc/libgcov-driver-system.c
libgcc/libgcov-driver.c

index 2a3094b216424039ac366aee5ceb221c9191ed2a..b70c037273194451e6872f3d987fe7cd85001609 100644 (file)
@@ -1,3 +1,9 @@
+2018-05-29  Martin Liska  <mliska@suse.cz>
+
+        PR gcov-profile/85759
+       * doc/gcov.texi: Document GCOV_ERROR_FILE and GCOV_EXIT_AT_ERROR
+       env variables.
+
 2018-05-29  Jakub Jelinek  <jakub@redhat.com>
 
        * tree-cfg.c (verify_gimple_assign_unary): Add checking for
index 4bd976db0b5dfcf54a9592215cfe2641f23d1bef..1cdca118b45fa055082db9a148104a6c3ab6abd7 100644 (file)
@@ -801,6 +801,14 @@ as well as handlers registered with @code{atexit}.
 If an executable loads a dynamic shared object via dlopen functionality,
 @option{-Wl,--dynamic-list-data} is needed to dump all profile data.
 
+Profiling run-time library reports various errors related to profile
+manipulation and profile saving.  Errors are printed into standard error output
+or @samp{GCOV_ERROR_FILE} file, if environment variable is used.
+In order to terminate immediately after an errors occurs
+set @samp{GCOV_EXIT_AT_ERROR} environment variable.
+That can help users to find profile clashing which leads
+to a misleading profile.
+
 @c man end
 
 @node Gcov Data Files
index 1b24190cf303ecd9af9f133ff16635ff78783a0d..7394b1fe341b28d1791e47e7a717c9f842e5e1ec 100644 (file)
@@ -1,3 +1,11 @@
+2018-05-29  Martin Liska  <mliska@suse.cz>
+
+        PR gcov-profile/85759
+       * libgcov-driver-system.c (gcov_error): Introduce usage of
+        GCOV_EXIT_AT_ERROR env. variable.
+       * libgcov-driver.c (merge_one_data): Print error that we
+        overwrite a gcov file with a different timestamp.
+
 2018-05-23  Kalamatee  <kalamatee@gmail.com>
 
        * config/m68k/lb1sf68.S (Laddsf$nf): Fix sign bit handling in
index 0df44239363542418910d6d40808ec357c5dfaec..bf125869dc08c64363156534a74c1b23e81e8f27 100644 (file)
@@ -62,8 +62,16 @@ gcov_error (const char *fmt, ...)
   va_list argp;
 
   va_start (argp, fmt);
-  ret = vfprintf (get_gcov_error_file (), fmt, argp);
+  FILE *f = get_gcov_error_file ();
+  ret = vfprintf (f, fmt, argp);
   va_end (argp);
+
+  if (getenv ("GCOV_EXIT_AT_ERROR"))
+    {
+      fprintf (f, "profiling:exiting after an error\n");
+      exit (1);
+    }
+
   return ret;
 }
 
index b4f195b825928d239fc7cca1110046ba36d73856..610356383f1541461ebd7ca545f11667d2824963 100644 (file)
@@ -372,8 +372,12 @@ merge_one_data (const char *filename,
 
   length = gcov_read_unsigned ();
   if (length != gi_ptr->stamp)
-    /* Read from a different compilation. Overwrite the file.  */
-    return 0;
+    {
+      /* Read from a different compilation.  Overwrite the file.  */
+      gcov_error ("profiling:%s:overwriting an existing profile data "
+                 "with a different timestamp\n", filename);
+      return 0;
+    }
 
   /* Look for program summary.  */
   for (f_ix = 0;;)