How does one get the actual function names from these output

99封情书 提交于 2019-12-22 04:33:17

问题


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


回答1:


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.




回答2:


Use c++filt, like this:

 $c++filt -n _ZN7UtilLib11ProgressBarC2EjdRSo

which outputs:

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


来源:https://stackoverflow.com/questions/14891764/how-does-one-get-the-actual-function-names-from-these-output

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!