@@ -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
@@ -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;
}
@@ -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;;)