为什么gcc 4.1 + gcov报告100%分支机构覆盖率和更新(4.4,4.6,4.8)报告“p =新类的50%”;线? [英] Why gcc 4.1 + gcov reports 100% branch coverage and newer (4.4, 4.6, 4.8) reports 50% for "p = new class;" line?

查看:247
本文介绍了为什么gcc 4.1 + gcov报告100%分支机构覆盖率和更新(4.4,4.6,4.8)报告“p =新类的50%”;线?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当gcc 4.1(使用gcov)下一行时:

p =新类; 已报告

作为100%的分支覆盖范围< - 这对我来说是好的。



为什么使用gcc 4.4及更高版本的同一行报告为:

[+ - ] p = new Class; (50%的分支机构覆盖率)...< - 这是覆盖100%的问题!!!



我可以为更新的gcc版本设置任何额外选项为了报告与gcc 4.1相同的分支覆盖率,单行为p = new Class;。

预先感谢。

解决方案

解决方案!



我们有一些C / C ++文件有和没有异常处理,所以lcov / gcov进程每个代码块的异常处理。



在一个普通块内,例如:

  int main(void)
{
...
...
[+ - ] printf(Hello \\\
);
...
}

gcov报告printf行有一个分支覆盖率为50%--->为什么?



由于异常处理已启用!!!

为了解决这个问题,请指定:


-fno-exceptions

在g ++命令行中。



示例:


g ++ -O0 --coverage -fno-exceptions -fno-inline ....

谢谢!


When gcc 4.1 (using gcov) next line:

p = new Class;

is reported as 100% branch coverage <-- THIS IS OK for me.

Why using gcc 4.4 and higher same line is reportted as:

[+ -] p = new Class; (50% branch coverage)... <-- THIS IS a problem for covering 100% !!!

Can I set any extra options to newer gcc versions in order to report same branch coverage as gcc 4.1 for single lines as "p = new Class;".

Thanks in advance.

解决方案

Solved !

We have some C/C++ files with and without exceptions handling, so lcov/gcov process "exceptions handling" for each code block.

Inside a normal block, for example:

int main(void)
{
 ...
 ...
 [+ -] printf("Hello\n");
 ...
}

gcov reports that printf line has a "branch coverage" of 50% ---> WHY ?

Because exceptions handling is enabled !!!

In order to solve this issue, specify:

-fno-exceptions

in g++ command line.

Example:

g++ -O0 --coverage -fno-exceptions -fno-inline ....

Thanks !

这篇关于为什么gcc 4.1 + gcov报告100%分支机构覆盖率和更新(4.4,4.6,4.8)报告“p =新类的50%”;线?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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