Bug 35568 - missing gcov data spoils other files.
Summary: missing gcov data spoils other files.
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: gcov-profile (show other bugs)
Version: 4.3.0
: P3 normal
Target Milestone: ---
Assignee: Steven Bosscher
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-03-13 14:44 UTC by Matt Rice
Modified: 2013-05-14 13:00 UTC (History)
3 users (show)

See Also:
Host:
Target:
Build:
Known to work: 4.7.1, 4.8.0
Known to fail: 4.6.3
Last reconfirmed: 2012-07-26 00:00:00


Attachments
the recovery of the functions variable was missing in a case of missing graph file (214 bytes, patch)
2010-03-26 00:09 UTC, Ádám Rák
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Matt Rice 2008-03-13 14:44:36 UTC
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'
Comment 1 Ádám Rák 2010-03-26 00:09:47 UTC
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.
Comment 2 Steven Bosscher 2012-07-26 20:34:52 UTC
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.
Comment 3 Steven Bosscher 2012-07-26 22:42:35 UTC
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.
Comment 4 David Claessens 2013-05-14 13:00:40 UTC
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'