This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug other/11651] New: gcov aborts if empty .da files (patch attached)
- From: "laurent dot deniel at free dot fr" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 23 Jul 2003 21:38:12 -0000
- Subject: [Bug other/11651] New: gcov aborts if empty .da files (patch attached)
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11651
Summary: gcov aborts if empty .da files (patch attached)
Product: gcc
Version: 3.2.3
Status: UNCONFIRMED
Severity: enhancement
Priority: P2
Component: other
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: laurent dot deniel at free dot fr
CC: gcc-bugs at gcc dot gnu dot org
GCC build triplet: any-any-any
GCC host triplet: any-any-any
GCC target triplet: any-any-any
Sometimes it is required to create empty .da files with appropriate
rights to be able to run the instrumented executable with different users.
But then, if some source files have not been executed, some .da files
remain empty making gcov aborts.
The simple fix below simply does the same thing with empty .da file as
if the file was not present.
--- gcov.c.ori 2003-07-23 22:17:41.000000000 +0200
+++ gcov.c 2003-07-23 22:25:50.000000000 +0200
@@ -471,6 +471,18 @@
fnotice (stderr, "Could not open data file %s.\n", da_file_name);
fnotice (stderr, "Assuming that all execution counts are zero.\n");
}
+
+ /* Check for empty .da file. Just assume that all execution counts are
+ zero in this case. */
+ /* Set the EOF condition if at the end of file. */
+ ungetc (getc (da_file), da_file);
+ if (feof (da_file))
+ {
+ fnotice (stderr, "data file %s is empty.\n", da_file_name);
+ fnotice (stderr, "Assuming that all execution counts are zero.\n");
+ fclose(da_file);
+ da_file = NULL;
+ }
bbg_file = fopen (bbg_file_name, "rb");
if (bbg_file == NULL)