1

I want to use a different gcc than my system defaults to to build a project. Therefore I need to provide lcov with the correct gcov-tool version. Unfortunately the --gcov-tool flag does not work for me. Not even with the version lcov should default to.

Sample run:

############## extract test coverage  ##############
g++-8 (Debian 8.3.0-6) 8.3.0
Copyright (C) 2018 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-tool-8 (Debian 8.3.0-6) 8.3.0
Copyright (C) 2018 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.

+ echo 'will work!'
will work!
+ lcov --capture --directory /data/home/extcpp/repos/extcpp/libext-build/debug --output-file test_coverage.info
Capturing coverage data from /data/home/extcpp/repos/extcpp/libext-build/debug
Found gcov version: 8.3.0
Scanning /data/home/extcpp/repos/extcpp/libext-build/debug for .gcda files ...
Found 25 data files in /data/home/extcpp/repos/extcpp/libext-build/debug
Processing CMakeFiles/ext_shared.dir/src/logging.cpp.gcda
Processing external_libs/googletest/googletest/CMakeFiles/gtest.dir/src/gtest-all.cc.gcda
Processing tests/CMakeFiles/test_libext_shared.dir/logging.cpp.gcda
Processing tests/CMakeFiles/test_libext_shared.dir/gtest.cpp.gcda
Processing tests/CMakeFiles/test_libext.dir/util_cast.cpp.gcda
Processing tests/CMakeFiles/test_libext.dir/math.cpp.gcda
Processing tests/CMakeFiles/test_libext.dir/algorithm_knapsack.cpp.gcda
Processing tests/CMakeFiles/test_libext.dir/util_enum.cpp.gcda
Processing tests/CMakeFiles/test_libext.dir/util_serialization.cpp.gcda
Processing tests/CMakeFiles/test_libext.dir/util_lazy.cpp.gcda
Processing tests/CMakeFiles/test_libext.dir/util_encode.cpp.gcda
Processing tests/CMakeFiles/test_libext.dir/meta_is_one_of.cpp.gcda
Processing tests/CMakeFiles/test_libext.dir/util_endian.cpp.gcda
Processing tests/CMakeFiles/test_libext.dir/util_result.cpp.gcda
Processing tests/CMakeFiles/test_libext.dir/util_scoped_timer.cpp.gcda
Processing tests/CMakeFiles/test_libext.dir/util_except.cpp.gcda
Processing tests/CMakeFiles/test_libext.dir/util_string.cpp.gcda
Processing tests/CMakeFiles/test_libext.dir/algorithm_string_distances.cpp.gcda
Processing tests/CMakeFiles/test_libext.dir/util_any_printable.cpp.gcda
Processing tests/CMakeFiles/test_libext.dir/gtest.cpp.gcda
Processing tests/CMakeFiles/test_libext.dir/meta_if.cpp.gcda
Processing tests/CMakeFiles/test_libext.dir/util_basic.cpp.gcda
Processing tests/CMakeFiles/test_libext.dir/util_windows_strings.cpp.gcda
geninfo: WARNING: gcov did not create any files for /data/home/extcpp/repos/extcpp/libext-build/debug/tests/CMakeFiles/test_libext.dir/util_windows_strings.cpp.gcda!
Processing tests/CMakeFiles/test_libext.dir/algorithm_basic.cpp.gcda
Processing tests/CMakeFiles/test_libext.dir/meta_has_member.cpp.gcda
Finished .info-file creation
+ echo 'will fail!' 
will fail!
++ type -p gcov-tool-8
+ lcov --capture --directory /data/home/extcpp/repos/extcpp/libext-build/debug --gcov-tool /usr/bin/gcov-tool-8 --output-file test_coverage.info
Capturing coverage data from /data/home/extcpp/repos/extcpp/libext-build/debug
Found gcov version: 8.3.0
Scanning /data/home/extcpp/repos/extcpp/libext-build/debug for .gcda files ...
Found 25 data files in /data/home/extcpp/repos/extcpp/libext-build/debug
Processing CMakeFiles/ext_shared.dir/src/logging.cpp.gcda
Usage: gcov-tool-8 [OPTION]... SUB_COMMAND [OPTION]...

Offline tool to handle gcda counts

  -h, --help                            Print this help, then exit
  -v, --version                         Print version number, then exit
  merge [options] <dir1> <dir2>         Merge coverage file contents
    -o, --output <dir>                  Output directory
    -v, --verbose                       Verbose mode
    -w, --weight <w1,w2>                Set weights (float point values)
  rewrite [options] <dir>               Rewrite coverage file contents
    -n, --normalize <int64_t>           Normalize the profile 
    -o, --output <dir>                  Output directory
    -s, --scale <float or simple-frac>  Scale the profile counters
    -v, --verbose                       Verbose mode
  overlap [options] <dir1> <dir2>       Compute the overlap of two profiles
    -f, --function                      Print function level info
    -F, --fullname                      Print full filename
    -h, --hotonly                       Only print info for hot objects/functions
    -o, --object                        Print object level info
    -t <float>, --hot_threshold <float> Set the threshold for hotness
    -v, --verbose                       Verbose mode

For bug reporting instructions, please see:
<file:///usr/share/doc/gcc-8/README.Bugs>.
geninfo: ERROR: GCOV failed for /data/home/extcpp/repos/extcpp/libext-build/debug/CMakeFiles/ext_shared.dir/src/logging.cpp.gcda!
+ ferr 'failed to extract coverage'
+ echo 'failed to extract coverage'
failed to extract coverage
+ exit 1
  • Can you provide output of /usr/bin/gcov-tool-8 /data/home/extcpp/repos/extcpp/libext-build/debug/CMakeFiles/ext_shared.dir/src/logging.cpp.gcda -o /data/home/extcpp/repos/extcpp/libext-build/debug/CMakeFiles/ext_shared.dir/src/ -b -c -p -a – Abhishek Agarwal Oct 26 '19 at 13:38

1 Answers1

5

I think you are confusing gcov-tool binary with gcov binary.

--gcov-tool option of lcov, expects gcov binary and not gcov-tool binary

For my system, the gcov binary is present in same folder as that of gcc

which gcc

/usr/bin/gcc

which gcov

/usr/bin/gcov

which gcov-tool

/usr/bin/gcov-tool

So For me

lcov --capture --directory /home/user/mydir

is equivalent to

lcov --capture --directory /home/user/mydir --gcov-tool /usr/bin/gcov

And below would be incorrect(Which is what you are trying to do)

lcov --capture --directory /home/user/mydir --gcov-tool /usr/bin/gcov-tool
Abhishek Agarwal
  • 694
  • 1
  • 9
  • 25