gcovr infinite loop when root directory specified

428 views Asked by At

Background
I am using the python tool gcovr to produce coverage data for some of my c projects. I am able to get the coverage data with no problems, but I'm not able to see which lines of code are covered due to a problem with the tool finding my source files.

After inspecting the XML data generated by gcovr I realized that the tool was looking at the wrong directory for coverage information. That being the case I specified the root for source files as specified by the documentation for gcovr.

# gcovr ... --object-directory=/some/path -r /some/path  

However, when I specify the directory for my source files, gcovr goes into an infinite loop.

Question
What is causing this infinite loop and what do I need to do to specify what directory my source files reside in?

If any extra information is needed to solve this problem, I am willing to provide what I can.

2

There are 2 answers

0
Bill Hart On BEST ANSWER

This issue is resolved in gcovr 3.2

0
user3784467 On

There is a documented bug in gcovr 3.1 with the handling of the "-r" (or "--root=") option. The bug causes gcovr to search for gcda files from the "/" level, which takes a long time. The fix is to surround the argument "options.root" with square brackets at line 1828, ie get_datafiles([options.root]). Please refer to https://github.com/gcovr/gcovr/pull/27 for more information.

In order to get gcovr 3.1 to set the source link correctly when the source was higher in the directory tree than the object (and gcno) directory, I had to apply the fix to issues 27 (root infinite loop), 42 (fix gcov incorrect relative path), and 49 (gcovr cannot find source files with gcov 4.8.2). Here is a visual of my source area:

src/foo/*.cc

src/foo/.obj/variant/*.o