This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: gprof skips std::ofstream methods
- From: John Reiser <jreiser at bitwagon dot com>
- To: binutils at sourceware dot org
- Date: Mon, 26 Apr 2010 21:38:55 -0700
- Subject: Re: gprof skips std::ofstream methods
- References: <BAY110-W8B7CE87C7DF10AD9CD2B996030@phx.gbl>
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.
--