This is the mail archive of the mailing list for the binutils project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: gprof skips std::ofstream methods

>> The only function that appears in the profiling results is
>> std::operator|(std::_Ios_Openmode, std::_Ios_Openmode)
>> Neither of ofstream::ofstream(), ofstream::write(), or ofstream::close()
>> appear. Am I missing some options perhaps that would make these appear?

> gprof does not handle shared libraries.  gprof has had this deficiency
> since its introduction in 1982, more than one quarter of a century ago.
> Most of the member functions of ofstream are in the shared library
>, and not in ./test:
>       $ nm ./test  |  c++filt  |  grep stream
>                   U std::basic_ostream<char, std::char_traits<char>>::write(char const*, long)@@GLIBCXX_3.4
>                   U std::basic_ofstream<char, std::char_traits<char>>::close()@@GLIBCXX_3.4
>                   U std::basic_ofstream<char, std::char_traits<char>>::basic_ofstream(char const*, std::_Ios_Openmode)@@GLIBCXX_3.4
>                   U std::basic_ofstream<char, std::char_traits<char>>::~basic_ofstream()@@GLIBCXX_3.4
> where the " U " means undefined in ./test .  In contrast,
>       $ nm ./test  |  c++filt  |  grep operator
>       00000000004009d0 W std::operator|(std::_Ios_Openmode, std::_Ios_Openmode)
> is defined as a Weak symbol (" W ") in ./test.

I tried linking libstdc++ statically, like this:
$ ln -s `g++ -print-file-name=libstdc++.a`
$ g++ -pg -static-libgcc -L. -o test test.cpp

I then ran
$ nm ./test | c++filt | grep ofstream
and this time the ofstream methods had "W" beside them
(and there were more of them than before).
However, gprof still only shows 
std::operator|(std::_Ios_Openmode, std::_Ios_Openmode)
and not any of the ofstream methods.
What am I still doing wrong?

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]