gprof skips std::ofstream methods

John Reiser jreiser@bitwagon.com
Tue Apr 27 04:39:00 GMT 2010


> 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.

The static library ./libstdc++.a was not compiled with any profiling
options.  Invoke a debugger such as gdb, and disassemble the first dozen
or so instructions at each entry point of ofstream methods.  There are
no calls to 'mcount' such as
     (gdb) x/12i main
         [[snip]]
     0x4028a2 <main(void)+14>:	callq  0x402640 <mcount@plt>
Therefore the profile output lacks entrance counts for any ofstream
methods that reside in ./libstdc++.a.  You'll have to find or create
a version of libstdc++ that was compiled with profiling options, or
"wrap" each method in your own code, then compile the wrappers using
profiling options.

The dynamic program counter sampling is performed at a rate of 100 to
1000 Hz, which is too infrequent to catch most single activations
of ofstream methods.

The landscape is littered with profiling projects, most of them dead.
There aren't enough paying customers.

-- 



More information about the Binutils mailing list