gprof skips std::ofstream methods

John Reiser jreiser@bitwagon.com
Sun Apr 25 03:01:00 GMT 2010


> 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
libstdc++.so.6, 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.

-- 



More information about the Binutils mailing list