This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: function instrumentation
ratheesh kannoth <ratheesh.ksz@gmail.com> writes:
> I would like to instrument cpp file using finstrument functions. I
> have written all the files and build script.
> I noticed that - the moment i add iostream header file into
> test.cpp file , the program segmentaion faults.
> void __cyg_profile_func_enter (void *func, void *caller)
> {
> helloworld() ;
> }
> int helloworld ()
> {
> std::cout << "hello " ;
> }
The compiler inserts a call to your profiling function before every
function. Your profiling function calls std::cout::operator<<. That
function inlined into your code from <iostream.h>, and the compiler
inserts a call to the profiling function at the start of it. Thus you
have an infinite recursion and your program crashes when it overruns the
stack.
Ian