gpt4 book ai didi

c++ - 如何使用带有 `--gcov-tool` 标志的 lcov?

转载 作者:行者123 更新时间:2023-11-28 04:06:56 25 4
gpt4 key购买 nike

我想使用与系统默认设置不同的 gcc 来构建项目。因此我需要为 lcov 提供正确的 gcov-tool 版本。不幸的是,--gcov-tool 标志对我不起作用。即使是 lcov 应该默认的版本也不行。

样本运行:

############## 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

最佳答案

我认为您混淆了 gcov-tool binary 和 gcov binary。

--lcov 的 gcov-tool 选项,需要 gcov 二进制而不是 gcov-tool 二进制

对于我的系统,gcov 二进制文件与 gcc 存在于同一文件夹中

哪个海合会

/usr/bin/gcc

哪个gcov

/usr/bin/gcov

哪个 gcov 工具

/usr/bin/gcov-tool

对我来说

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

相当于

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

下面是不正确的(这就是你想要做的)

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

关于c++ - 如何使用带有 `--gcov-tool` 标志的 lcov?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58570285/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com