0

I'm using Cygwin GCC 11.2.0 on Win10 with gcovr 5.0. My C files are compiled with the --coverage flag and the .gcno files are created. After running my program the .gcda files exist as well and if I open them in Eclipse with the GCOV extension I see valid coverage data. But when I run gcovr with the command gcovr -v -r X:/Path/to/my/Project . (this folder contains sub-folders with my .c and .h files) I see the following output

------------------------------------------------------------------------------
                           GCC Code Coverage Report
Directory: X:/Path/to/my/Project
------------------------------------------------------------------------------
File                                       Lines    Exec  Cover   Missing
------------------------------------------------------------------------------
------------------------------------------------------------------------------
TOTAL                                          0       0    --%
------------------------------------------------------------------------------

Thanks to the -v (verbose) option I can see that all files are processed e.g.

Processing file: C:\Path\to\my\object\folder\02_obj\filename.gcda
Running gcov: 'gcov C:\Path\to\my\object\folder\02_obj\filename.gcda --branch-counts --branch-probabilities --preserve-paths --object-directory     C:\Path\to\my\object\folder\02_obj' in 'C:\Users\Name\AppData\Local\Temp\tmpncjbaf67'

But it ends always with Gathered coveraged data for 0 files. I can also let gcovr generate a HTML output file with the option --html -o output.html but this shows no results.

My project structure is the following

.c files: X:\Project\Implementation\dev\Source_File_Folder

.o, .gcno, .gcda files: X:\Project\Verification\Test\VariantABC\Binaries\Obj_Folder

The call

X:\Project\Implementation\dev\Source_File_Folder>gcovr -v X:\Project\Verification\Test\VariantABC\Binaries\Obj_Folder -r .

Gave me the following result

Filters for --root: (1)
-re.compile('^X:\\\\Project\\\\Implementation\\\\dev\\\\ProjektGitRepo\\\\Source_File_Folder\\\\')
Filters for --filter: (1)
-DirectoryPrefixFilter(X:\Project\Implementation\dev\Source_File_Folder\)
Filters for --exclude: (0)
Filters for --gcov-filter: (1)
- AlwaysMatchFilter()
Filters for --gcov-exclude: (0)
Filters for --exclude-directories: (0)
Scanning directory     X:\Project\Verification\Test\VariantABC\Binaries\Obj_Folder for gcda/gcno files...
Found 21 files (and will process 11)
Pool started with 1 threads
Processing file: X:\Project\Verification\Test\VariantABC\Binaries\Obj_Folder\bap_bcl.gcda
Running gcov: 'gcov X:\Project\Verification\Test\VariantABC\Binaries\Obj_Folder\bap_bcl.gcda --branch-counts --branch-probabilities --preserve-paths --object-directory X:\Project\Verification\Test\VariantABC\Binaries\Obj_Folder' in 'C:\Users\Name\AppData\Local\Temp\tmppd7r7jwv'
Processing file: X:\Project\Verification\Test\VariantABC\Binaries\Obj_Folder\bap_bpl.gcda
Running gcov: 'gcov X:\Project\Verification\Test\VariantABC\Binaries\Obj_Folder\bap_bpl.gcda --branch-counts --    branch-probabilities --preserve-paths --object-directory X:\Project\Verification\Test\VariantABC\Binaries\Obj_Folder\02_obj' in 'C:\Users\Name\AppData\Local\Temp\tmppd7r7jwv'
Processing file: ... this continues for the remaining 19 files
Gathered coveraged data for 0 files
------------------------------------------------------------------------------
                           GCC Code Coverage Report
Directory: .
------------------------------------------------------------------------------
File                                       Lines    Exec  Cover   Missing
------------------------------------------------------------------------------
------------------------------------------------------------------------------
TOTAL                                          0       0    --%
------------------------------------------------------------------------------

How can I run gcovr sucessfully?

Edit I have now added a script that is called instead of gcov. It replaces all backslashes by slashes in the parameter list for gcov and then calls gcov. This is the implementation:

gcov_replace_backslash.bat:
@echo off
set "parameters=%*"
set "parameters=%parameters:\=/%"
gcov %parameters%

When using this script with gcovr by setting the parameter --gcov-executable I get a diferent but still not the desired result:

X:\Implementation\dev\Source>gcovr -v --gcov-executable gcov_replace_backslash.bat X:/Verification/Test/Integration/obj -r .
Filters for --root: (1)
- re.compile('^X:\\\\Implementation\\\\dev\\\\Source\\\\')
Filters for --filter: (1)
- DirectoryPrefixFilter(C:/Users/Name/Projekt/Implementation/dev/Source/)
Filters for --exclude: (0)
Filters for --gcov-filter: (1)
- AlwaysMatchFilter()
Filters for --gcov-exclude: (0)
Filters for --exclude-directories: (0)
Scanning directory X:/Verification/Test/Integration/obj for gcda/gcno files...
Found 21 files (and will process 11)
Pool started with 1 threads
Processing file: C:\Users\Name\Projekt\Verification\Test\Integration\obj\file1.gcda
Running gcov: 'gcov_replace_backslash.bat C:\Users\Name\Projekt\Verification\Test\Integration\obj\file1.gcda --branch-counts --branch-probabilities --preserve-paths --object-directory C:\Users\Name\Projekt\Verification\Test\Integration\_obj' in 'C:\Users\Name\AppData\Local\Temp\tmpdlm9xrfx'
Finding source file corresponding to a gcov data file
  currdir      X:\Implementation\dev\Source
  gcov_fname   C:\Users\Name\AppData\Local\Temp\tmpdlm9xrfx\#cygdrive#X#Implementation#dev#Source#file1.c.gcov
               ['        -', '    0', 'Source', '/cygdrive/X/Implementation/dev/Source/file1.c\n']
  source_fname C:\Users\Name\Projekt\Verification\Test\Integration\obj\file1.gcda
  root         X:\Implementation\dev\Source
  fname        C:\Users\Name\Projekt\Verification\Test\Integration\obj\file1.c
Parsing coverage data for file C:\Users\Name\Projekt\Verification\Test\Integration\obj\file1.c
  Filtering coverage data for file C:\Users\Name\Projekt\Verification\Test\Integration\obj\file1.c
Processing file: C:\Users\Name\Projekt\Verification\Test\Integration\obj\file2.gcda
Running gcov: 'gcov_replace_backslash.bat C:\Users\Name\Projekt\Verification\Test\Integration\obj\file2.gcda --branch-counts --branch-probabilities --preserve-paths --object-directory C:\Users\Name\Projekt\Verification\Test\Integration\_obj' in 'C:\Users\Name\AppData\Local\Temp\tmpdlm9xrfx'
Finding source file corresponding to a gcov data file
  currdir      X:\Implementation\dev\Source
  gcov_fname   C:\Users\Name\AppData\Local\Temp\tmpdlm9xrfx\#cygdrive#X#Implementation#dev#Source#file2.c.gcov
               ['        -', '    0', 'Source', '/cygdrive/X/Implementation/dev/Source/file2.c\n']
  source_fname C:\Users\Name\Projekt\Verification\Test\Integration\obj\file2.gcda
  root         X:\Implementation\dev\Source
  fname        C:\Users\Name\Projekt\Verification\Test\Integration\obj\file2.c
Parsing coverage data for file C:\Users\Name\Projekt\Verification\Test\Integration\obj\file2.c
  Filtering coverage data for file C:\Users\Name\Projekt\Verification\Test\Integration\obj\file2.c
Processing file: ... for the remaining files

Gathered coveraged data for 0 files
------------------------------------------------------------------------------
                           GCC Code Coverage Report
Directory: .
------------------------------------------------------------------------------
File                                       Lines    Exec  Cover   Missing
------------------------------------------------------------------------------
------------------------------------------------------------------------------
TOTAL                                          0       0    --%
------------------------------------------------------------------------------
Daniel
  • 403
  • 2
  • 15
  • Could you provide more context about the layout of your project directory, and about the directory from which you run gcovr? To me, this looks like either gcovr can't figure out how to run gcovr successfully, or all the source code files are outside of the root directory you specified. More from the --verbose output would be helpful – are there lines like “Filtering coverage data for file …”? – amon Jan 07 '22 at 18:31
  • @amon: I have added my folder structures in detail (I only replaced some folder names) – Daniel Jan 10 '22 at 08:12
  • Maybe the cause for my issue is this: https://github.com/gcovr/gcovr/issues/501 – Daniel Jan 10 '22 at 10:27
  • 1
    Hmm, that might be it. Practically speaking, the easiest workaround would be to create a script that wraps gcov and fixes the paths before calling the real gcov. You can then tell gcovr to use your script via `--gcov-executable="path/to/your/wrapper"`. – amon Jan 10 '22 at 23:04
  • @amon: I now have replaced the backslashes in the gcov parameters as described but gcovr is still not working. – Daniel Jan 13 '22 at 08:37
  • 1
    This is progress! GCC's `gcov` is now being executed correctly, but then gcovr gets confused by `/cygdrive/X/...` style paths. Maybe your Python was compiled for Windows, not Cygwin. Potential solutions: (a) Ensure that GCC/gcov/gcovr run in the same OS context (either Cygwin *or* Windows *or* WSL) – `python3 -c 'import sys; print(sys.platform)'` should be cygwin. (b) Patch gcovr to replace `/cygdrive/X/` paths with `X:/`, around [here](https://github.com/gcovr/gcovr/blob/5.0/gcovr/gcov.py#L150). But even then, some bugs might remain that will only be fixed with the upcoming gcovr 5.1 release. – amon Jan 13 '22 at 10:39

0 Answers0