2

A recent OS upgrade made my coverage script fail miserably.

lcov 1.13

gcov (GCC) 9.1.1

The part of my CMake that is used to generate coverage data:

if ($ENV{COVERAGE})
    message("Setting up for coverage")
    enable_testing()
    include(CodeCoverage)
    setup_target_for_coverage(${PROJECT_NAME}_coverage tests coverage)
    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}  --coverage")
endif ()

The lcov command I issued after building tests: lcov --capture --directory build/ --output-file coverage.info

Unfortunately now fails with:

Capturing coverage data from build/
Found gcov version: 9.1.1
Scanning build/ for .gcda files ...
geninfo: WARNING: no .gcda files found in build/ - skipping!
Finished .info-file creation

The error message makes sense because there are no .gcda files - only .gcno files. I am not sure if they serve the same purpose and / or can be used with lcov.

I issued nm some_binary | grep gcov and there are a lot of symbols in the form of:

00000000004b3520 d __gcov_._ZZZN6__pstl10__internal15__pattern_walk2IRKNS_9execution2v115parallel_policyEN9__gnu_cxx17__normal_iteratorIPKiSt6vectorIiSaIiEEEENS8_IPiSD_EEZSt9transformIS6_SE_SG_ZN12_GLOBAL__N_150ParallelTransformTest_NoDataShouldReturnEmpty_Test8TestBodyEvEUlRKT_E_ENSt9enable_ifIXsrNS3_19is_execution_policyINSt5decayISK_E4typeEEE5valueET1_E4typeEOSK_T0_SY_SU_T2_EUlRS9_RiE_St17integral_constantIbLb0EEEESU_SX_SY_SY_SU_SZ_T3_S13_IbLb1EEENKUlvE_clEvENKUlSE_SE_E_clESE_SE_

So I guess the CMake is still correctly trying to give me coverage data.

It worked fine on gcc 7 if I recall correctly.

Is there a new solution / CMake flag to issue / lcov flag to issue? Or is it broken right now and there is no workaround? Or perhaps I was doing something odd the whole time?

Leśny Rumcajs
  • 2,259
  • 2
  • 17
  • 33

1 Answers1

5

I believe GCC 9 outputs coverage data as JSON by default now, as mentioned in the change notes.

The gcov tool has changed its intermediate format to a new JSON format.

It also looks like lcov have an open issue for handling this new format.

Sam Rice
  • 261
  • 2
  • 5
  • It seems so. Any known workarounds? I'm not willing to recompile the whole project under different compiler version just to get coverage. – Leśny Rumcajs Jun 23 '19 at 08:37
  • 2
    The latest commit to master branch on lcov is actually supposed to address this, so you could try building lcov from source. I can't seem to find any suggestion that this is configurable in GCC, so that might be your only option at the moment. – Sam Rice Jun 23 '19 at 12:00
  • Yes, running `lcov` from master does allowed parsing the intermediate gcov format - though I needed to install additional packages like `zlib` or a bunch of Perl modules from `cpan`. Not really clean but does the trick. – Leśny Rumcajs Jun 23 '19 at 21:01