如何从这些输出获得实际的函数名称 [英] How does one get the actual function names from these output

查看:300
本文介绍了如何从这些输出获得实际的函数名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用boost测试进行单元测试,gcov和lcov用于测量覆盖率。



不幸的是genhtml生成的报告类似于函数覆盖:





我现在想知道函数 _ZN7UtilLib11ProgressBarC2EjdRSo 实际上是什么。



到目前为止我无法关联这个函数到任何ProgressBar的类接口:

  class ProgressBar {
public:
explicit ProgressBar b $ b unsigned int expected_count,
double updateInterval = 30,
std :: ostream& os = std :: cout);

unsigned int operator + =(unsigned int increment);

unsigned int operator ++();

unsigned int operator ++(int i);
}

任何人都可以帮助我如何获得更好的函数名称gcov或如何



应用程序使用gcc4.7编译,并带有以下标志: -g -g -save-temps = obj -Wall -Wextra -Wno-unused-parameter -Wno-error = unused-parameter -O0 -pedantic

解决方案

这些是经过修改的C ++符号,在shell中使用 c ++ filt 来解构:

 > c ++ filt _ZN7UtilLib11ProgressBarC2EjdRSo 
UtilLib :: ProgressBar :: ProgressBar(unsigned int,double,std :: basic_ostream< char,std :: char_traits< char>>&)

此外,由于您似乎使用 genhtml ,请查看

请注意,编译器会为您编写的ctor发出两个实现,使用 - demangle-cpp 将隐藏仅在已损坏的符号名称中可见的差异。要了解编译器正在执行的操作,请查看此处。 / p>

I use boost test for unit testing and gcov and lcov for measuring the coverage.

Unfortuanlly genhtml generates reports like that for function coverage:

I now want to know what the function _ZN7UtilLib11ProgressBarC2EjdRSo actually is.

So far I can not correlate this function to any of the class interface of ProgressBar:

class ProgressBar {
 public:
    explicit ProgressBar(
            unsigned int expected_count,
            double updateInterval = 30,
            std::ostream& os = std::cout);

    unsigned int operator+=(unsigned int increment);

    unsigned int operator++();

    unsigned int operator++(int i);
}

Can any one help me how to either get better function names with gcov or how does one understand these function names.

The application is compiled with gcc4.7 with the following flags:-g -g -save-temps=obj -Wall -Wextra -Wno-unused-parameter -Wno-error=unused-parameter -O0 -pedantic

解决方案

These are mangled C++ symbols, use c++filt in a shell to demangle it:

> c++filt _ZN7UtilLib11ProgressBarC2EjdRSo
UtilLib::ProgressBar::ProgressBar(unsigned int, double, std::basic_ostream<char, std::char_traits<char> >&)

Also, since you seem to use genhtml, check out the --demangle-cpp option to do the demangling automatically for you.

Note that the compiler emits two implementations for the ctor you wrote, using --demangle-cpp will hide the difference which is visible only in the mangled symbol name. To understand what the compiler is doing, have a look here.

这篇关于如何从这些输出获得实际的函数名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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