使用gcov进行交叉分析,但是忽略了GCOV_PREFIX和GCOV_PREFIX_STRIP [英] Crossprofiling with gcov, but GCOV_PREFIX and GCOV_PREFIX_STRIP is ignored

查看:572
本文介绍了使用gcov进行交叉分析,但是忽略了GCOV_PREFIX和GCOV_PREFIX_STRIP的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用GCOV进行代码覆盖,但是测试将在另一台计算机上运行.因此,可执行文件中.gcda文件的硬连线路径将不起作用.

I want to use GCOV to make code coverage but the tests will run on another machine. So the hard wired path to .gcda files in the executable won't work.

为了更改此默认目录,我可以使用GCOV_PREFIX和GCOV_PREFIX_STRIP环境变量,如

In order to change this default directory I can use the GCOV_PREFIX and GCOV_PREFIX_STRIP env vars, as it's said here.

这是我使用的命令:

$ export GCOV_PREFIX="/foo/bar"
$ export GCOV_PREFIX_STRIP="3"
$ gcc main.c -fprofile-arcs -ftest-coverage
$ strings a.out | grep gcda
/home/calmarius/blahblah/main.c.gcda

路径保持不变. 任何人都有经验吗?

The path remains the same. Anyone have experience with this?

推荐答案

运行代码时会考虑环境变量.

The environment variables are taken into account when you run the code.

在运行测试之前,将它们设置为目标计算机上的适当值,然后将在所需位置生成.gcda文件.

Set them to the appropriate values on the target machine before you run your tests, and the .gcda files will be generated where you want them.

这篇关于使用gcov进行交叉分析,但是忽略了GCOV_PREFIX和GCOV_PREFIX_STRIP的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆