gcc version 4.3.0 20080307 (Red Hat 4.3.0-2) (GCC) $ cat foo.sh #!/bin/sh cat >gcov_test.c <<EOF int main() { return 0; } EOF gcc gcov_test.c -o gcov_test -fprofile-arcs -ftest-coverage ./gcov_test gcov *.c touch unused.c gcov *.c $ sh foo.sh File 'gcov_test.c' Lines executed:100.00% of 2 gcov_test.c:creating 'gcov_test.c.gcov' unused.gcno:cannot open graph file File 'gcov_test.c' No executable lines gcov_test.c:creating 'gcov_test.c.gcov'
Created attachment 20202 [details] the recovery of the functions variable was missing in a case of missing graph file it seems like the author of the code intended to set the functions variable in case of a failure, and saved the original into old_functions, but forgot to actually do it in case there are no graph file to the currently processed .c file.
Still happens for: "xgcc (GCC) 4.8.0 20120726 (experimental) [trunk revision 189887]" $ sh -x foo.sh + cat + gcc gcov_test.c -o gcov_test -fprofile-arcs -ftest-coverage + ./gcov_test + gcov gcov_test.c File 'gcov_test.c' Lines executed:100.00% of 2 gcov_test.c:creating 'gcov_test.c.gcov' + cat gcov_test.c.gcov -: 0:Source:gcov_test.c -: 0:Graph:gcov_test.gcno -: 0:Data:gcov_test.gcda -: 0:Runs:1 -: 0:Programs:1 1: 1:int main() -: 2:{ 1: 3: return 0; -: 4:} + touch gcov_test2.c + gcov gcov_test.c gcov_test2.c gcov_test2.gcno:cannot open graph file File 'gcov_test.c' No executable lines gcov_test.c:creating 'gcov_test.c.gcov' + cat gcov_test.c.gcov -: 0:Source:gcov_test.c -: 0:Programs:1 -: 1:int main() -: 2:{ -: 3: return 0; -: 4:} $ Mine.
Hmpf, not very smart to test the system compiler, which was GCC 4.6.3... GCC 4.7.1 and GCC 4.8.0 work: + rm -f gcov_test.gcda gcov_test.gcno + cat + ./xgcc --version xgcc (GCC) 4.8.0 20120726 (experimental) [trunk revision 189890] Copyright (C) 2012 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ./gcov --version gcov (GCC) 4.8.0 20120726 (experimental) [trunk revision 189890] Copyright (C) 2012 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ./xgcc -B. gcov_test.c -o gcov_test -fprofile-arcs -ftest-coverage + ./gcov_test + ./gcov gcov_test.c File 'gcov_test.c' Lines executed:100.00% of 2 Creating 'gcov_test.c.gcov' + cat gcov_test.c.gcov -: 0:Source:gcov_test.c -: 0:Graph:gcov_test.gcno -: 0:Data:gcov_test.gcda -: 0:Runs:1 -: 0:Programs:1 1: 1:int main() -: 2:{ 1: 3: return 0; -: 4:} + rm gcov_test.c.gcov + touch gcov_test2.c + ./gcov gcov_test.c gcov_test2.c gcov_test2.gcno:cannot open notes file File 'gcov_test.c' Lines executed:100.00% of 2 Creating 'gcov_test.c.gcov' Lines executed:100.00% of 2 + cat gcov_test.c.gcov -: 0:Source:gcov_test.c -: 0:Programs:1 1: 1:int main() -: 2:{ 1: 3: return 0; -: 4:} Closing, as this is not a regression for GCC 4.6.
This bug seems to regress a lot between versions on my development station (Linux Mint 13): $ gcov --version gcov (Ubuntu/Linaro 4.6.3-1ubuntu5) 4.6.3 $ gcov src/frames/framegrabcontroller.cpp --branch-counts --branch-probabilities --preserve-paths --object-directory build/intel-linux64/debug/intermediate/src/frames build/intel-linux64/debug/intermediate/src/frames/framegrabcontroller.gcda:cannot open data file, assuming not executed File 'src/frames/framegrabcontroller.cpp' Lines executed:0.00% of 78 Branches executed:0.00% of 270 Taken at least once:0.00% of 270 Calls executed:0.00% of 307 src/frames/framegrabcontroller.cpp:creating 'src#frames#framegrabcontroller.cpp.gcov' on our jenkins server (Debian Testing): $ gcov --version gcov (Debian 4.7.2-5) 4.7.2 $ gcov src/frames/framegrabcontroller.cpp --branch-counts --branch-probabilities --preserve-paths --object-directory build/intel-linux64/debug/intermediate/src/frames build/intel-linux64/debug/intermediate/src/frames/framegrabcontroller.gcda:cannot open data file, assuming not executed File 'src/frames/framegrabcontroller.cpp' No executable lines No branches No calls Removing 'src#frames#framegrabcontroller.cpp.gcov'