This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
function instrumentation
- From: ratheesh kannoth <ratheesh dot ksz at gmail dot com>
- To: gcc-help at gcc dot gnu dot org
- Date: Thu, 26 Jan 2012 22:01:49 +0530
- Subject: function instrumentation
Hi,
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.
What is the problem.
(gdb) r
Starting program: /home/fox/project_profile/a.out
Program received signal SIGSEGV, Segmentation fault.
0x00007ffff7b65bd1 in std::ostream::sentry::sentry(std::ostream&) ()
from /usr/lib/libstdc++.so.6
(gdb) bt
#0 0x00007ffff7b65bd1 in std::ostream::sentry::sentry(std::ostream&)
() from /usr/lib/libstdc++.so.6
#1 0x00007ffff7b664b8 in std::basic_ostream<char,
std::char_traits<char> >& std::__ostream_insert<char,
std::char_traits<char> >(std::basic_ostream<char,
std::char_traits<char> >&, char const*, long) () from
/usr/lib/libstdc++.so.6
#2 0x00007ffff7b668bf in std::basic_ostream<char,
std::char_traits<char> >& std::operator<< <std::char_traits<char>
>(std::basic_ostream<char, std::char_traits<char> >&, char const*) ()
from /usr/lib/libstdc++.so.6
#3 0x00000000004008cf in helloworld () at possol.cpp:5
#4 0x00000000004008a9 in __cyg_profile_func_enter (func=0x4009e2,
caller=0x400ae6) at inst.cpp:13
#5 0x00000000004009f4 in global constructors keyed to main () at test.cpp:7
#6 0x0000000000400ae6 in __do_global_ctors_aux ()
#7 0x000000000040072b in _init ()
#8 0x00007fffffffe398 in ?? ()
#9 0x0000000000400a75 in __libc_csu_init ()
#10 0x00007ffff72cabe0 in __libc_start_main () from /lib/libc.so.6
#11 0x00000000004007d9 in _start ()
********************************* inst.cpp
*************************************
#include <stdio.h>
extern "C"
{
void __cyg_profile_func_enter (void *, void *)
__attribute__((no_instrument_function));
void __cyg_profile_func_exit (void *, void *)
__attribute__((no_instrument_function));
}
int helloworld();
void __cyg_profile_func_enter (void *func, void *caller)
{
helloworld() ;
}
void __cyg_profile_func_exit (void *func, void *caller)
{
}
************************** possol.cpp *************************************
#include <iostream>
int helloworld ()
{
std::cout << "hello " ;
}
******************************** test.cpp
***************************************
#inclde <iostream> /// You can avoid the segmentation fault, if u remove this.
int main()
{
return 0;
}
-Ratheesh
************************ build.sh *****************************
set -x
rm *.o
g++ -g -c inst.cpp
g++ -g -c possol.cpp
g++ -g -c test.cpp -finstrument-functions
g++ -g inst.o possol.o test.o