我如何使用 clang++ 获得代码覆盖率Mac 上的 13.0.1 吗?

发布于 2025-01-16 08:50:37 字数 863 浏览 3 评论 0原文

我正在尝试为 Mac 上使用 clang++ 13.0.1 编译的可执行文件创建代码覆盖率报告。 clang++ 和支持工具来自 LLVM 项目 github 站点上的 13.0.1 版本二进制文件下载。运行 clang++ --version 验证其版本是否为 13.0.1。

test 目标文件和可执行文件使用“-fprofile-instr-generate -fcoverage-mapping”标志进行编译和链接。运行测试会生成一个 .profraw 文件,如预期的那样:

LLVM_PROFILE_FILE="code-%6m.profraw" test

file code-18395704024281647848_0.profraw
code-18395704024281647848_0.profraw: LLVM raw profile data, version 5

不幸的是,当我尝试将 .profraw 文件转换为 .profdata 格式以供 llvm-cov 使用时,llvm-profdata 抱怨:

llvm-profdata merge code-18395704024281647848_0.profraw -o out.profdata
warning: code-18395704024281647848_0.profraw: unsupported instrumentation profile format version

也许我错过了一些很容易纠正的内容或那里是确定代码覆盖率的更好/更常见的方法。任何帮助表示赞赏!

I am trying to create a code coverage report for an executable compiled with clang++ 13.0.1 on Mac. The clang++ and support tools come from the 13.0.1 release binary download on the LLVM Project's github site. Running clang++ --version verifies that it is version 13.0.1.

The test object files and executable are compiled and linked using the "-fprofile-instr-generate -fcoverage-mapping" flags. Running the test generates a .profraw file, as expected:

LLVM_PROFILE_FILE="code-%6m.profraw" test

file code-18395704024281647848_0.profraw
code-18395704024281647848_0.profraw: LLVM raw profile data, version 5

Unfortunately, when i try to convert the .profraw file to .profdata format for use by llvm-cov, llvm-profdata complains:

llvm-profdata merge code-18395704024281647848_0.profraw -o out.profdata
warning: code-18395704024281647848_0.profraw: unsupported instrumentation profile format version

Perhaps i have missed something which is easily corrected or there is a better/more common approach for determining code coverage. Any help appreciated!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

她如夕阳 2025-01-23 08:50:37

我也有同样的问题。
在命令前添加xcrun可以解决这个问题。

xcrun llvm-profdata merge -sparse default.profraw -o default.profdata
xcrun llvm-cov show ./sum_up -instr-profile=default.profdata

I had the same problem.
Adding xcrun before the command solves this problem。

xcrun llvm-profdata merge -sparse default.profraw -o default.profdata
xcrun llvm-cov show ./sum_up -instr-profile=default.profdata
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文