【问题标题】:How does one get the actual function names from these output如何从这些输出中获取实际的函数名称
【发布时间】:2013-01-31 06:06:44
【问题描述】:

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

不幸的是,genhtml 会为函数覆盖率生成类似的报告:

我现在想知道_ZN7UtilLib11ProgressBarC2EjdRSo这个函数到底是什么。

到目前为止,我无法将此函数与 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);
}

谁能帮助我如何使用 gcov 获得更好的函数名称,或者如何理解这些函数名称。

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

【问题讨论】:

    标签: c++ gcov


    【解决方案1】:

    这些是损坏的 C++ 符号,在 shell 中使用 c++filt 对其进行解码:

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

    另外,由于您似乎使用genhtml,请查看--demangle-cpp 选项自动为您进行去错。

    请注意,编译器会为您编写的 ctor 发出两个实现,使用 --demangle-cpp 将隐藏仅在损坏的符号名称中可见的差异。要了解编译器在做什么,请查看here。

    【讨论】:

      【解决方案2】:

      使用c++filt,像这样:

       $c++filt -n _ZN7UtilLib11ProgressBarC2EjdRSo
      

      哪个输出:

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

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2020-01-21
        • 2020-04-08
        • 1970-01-01
        相关资源
        最近更新 更多