Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How does one get the actual function names from these output

Tags:

c++

gcov

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

Unfortuanlly genhtml generates reports like that for function coverage:

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

like image 706
tune2fs Avatar asked Feb 15 '13 09:02

tune2fs


2 Answers

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.

like image 80
Daniel Frey Avatar answered Sep 28 '22 23:09

Daniel Frey


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> >&)
like image 29
Mats Petersson Avatar answered Sep 29 '22 00:09

Mats Petersson