[Bug c++/14609] New: C++ profiling bug makes string constructor calls <spontaneous>

gcc-bugzilla at gcc dot gnu dot org gcc-bugzilla@gcc.gnu.org
Tue Mar 16 18:26:00 GMT 2004


Under certain circumstances, the gprof call graph for C++ code
compiled with -pg shows some std::string::string constructor calls as
"spontaneous".  In string-intensive programs, this makes profiling and
performance-tuning extremely painful.

Environment:
System: Linux razorfish 2.4.24-1-686 #1 Wed Feb 4 20:22:14 EST 2004 i686 GNU/Linux
Architecture: i686
host: i486-pc-linux-gnu
build: i486-pc-linux-gnu
target: i486-pc-linux-gnu
configured with: ../src/configure -v --enable-languages=c,c++,java,f77,pascal,objc,ada,treelang --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --with-gxx-include-dir=/usr/include/c++/3.3 --enable-shared --with-system-zlib --enable-nls --without-included-gettext --enable-__cxa_atexit --enable-clocale=gnu --enable-debug --enable-java-gc=boehm --enable-java-awt=xlib --enable-objc-gc i486-linux

How-To-Repeat:

Attached are Demo.cc (original source) and Demo.ii (preprocessed
source) for a program I believe demonstrates the problem.

Build Demo with this command:
g++ --save-temps -Wall -g -static -pg Demo.cc -o Demo

Run Demo like this:
./Demo

Then look for the problem with this command:
gprof -z Demo | grep -C1 std::string::string | less

(gprof is GNU gprof 2.14.90.0.7)

The problem shows up as a spontaneous std::string::string constructor
that calls std::string::_S_construct once:

------------------------------------------------------------
                                                 <spontaneous>
[1485]   0.0    0.00    0.00                 std::string::string(char const*, std::allocator<char> const&) [1485]
                0.00    0.00       1/1           char* std::string::_S_construct<char const*>(char const*, char const*, std::allocator<char> const&, std::forward_iterator_tag) [446]
------------------------------------------------------------

If you comment out either of the two unrelated constructors in main(),
and re-run the experiment, the mystery <spontaneous> stuff goes away.

If you build Demo using g++ 2.95, the problem does not occur at all.

-- 
           Summary: C++ profiling bug makes string constructor calls
                    <spontaneous>
           Product: gcc
           Version: 3.3
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: jhbrown at bluefinrobotics dot com
                CC: gcc-bugs at gcc dot gnu dot org
 GCC build triplet: i486-pc-linux-gnu
  GCC host triplet: i486-pc-linux-gnu
GCC target triplet: i486-pc-linux-gnu


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14609



More information about the Gcc-bugs mailing list