Tag: gcov

如何告诉gcov忽略C ++代码的不可击中的行?

我使用gcov来测量我的C ++代码的覆盖范围。 我想达到100%的覆盖率,但受到这样一个事实的阻碍:理论上有一些代码行是不可触发的(这些方法需要被实现但是从来没有被调用过,默认的switch语句分支,等等。)。 每个分支都包含一个assert( false ); 声明,但gcov仍然标志着他们未受打击。 我希望能够告诉gcov忽略这些分支。 有没有办法给gcov这些信息 – 通过注释的源代码,或通过任何其他机制?

gcov报告的析构函数中的分支是什么?

当我使用gcov来度量C ++代码的testing覆盖率时,它会在析构函数中报告分支。 struct Foo { virtual ~Foo() { } }; int main (int argc, char* argv[]) { Foo f; } 当我启用分支概率运行gcov(-b)时,我得到以下输出。 $ gcov /home/epronk/src/lcov-1.9/example/example.gcda -o /home/epronk/src/lcov-1.9/example -b File 'example.cpp' Lines executed:100.00% of 6 Branches executed:100.00% of 2 Taken at least once:50.00% of 2 Calls executed:40.00% of 5 example.cpp:creating 'example.cpp.gcov' 困扰我的部分是“至less一次:2的50.00%”。 生成的.gcov文件给出了更多的细节。 $ cat example.cpp.gcov | […]

gcov符号在哪里?

我试图用gcov编译一个简单的应用程序,并得到以下链接错误: gcc AllTests.o CuTestTest.o CuTest.o -o TestTest AllTests.o: In function `global constructors keyed to 0_RunAllTests': /home/p7539c/cutest/AllTests.c:26: undefined reference to `__gcov_init' AllTests.o:(.data+0x44): undefined reference to `__gcov_merge_add' CuTestTest.o: In function `global constructors keyed to 0_TestCuStringNew': /home/p7539c/cutest/CuTestTest.c:30: undefined reference to `__gcov_init' CuTestTest.o:(.data+0x64): undefined reference to `__gcov_merge_add' CuTest.o: In function `global constructors keyed to 0_CuStrAlloc': /home/p7539c/cutest/CuTest.c:379: undefined reference to […]