Re: function instrumentation

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Jan 26, 2012 at 19:04, ratheesh kannoth <ratheesh.ksz@xxxxxxxxx> wrote:
> Hi,
>
> I would like to instrument cpp file using finstrument functions of gcc
> (4.4.3)  . 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.

GCC also instruments inline functions, and iostream is probably full
of them. You could try to exclude them with the
-finstrument-functions-exclude-file-list=/usr/include flag.

Bert

>
> (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;
> }
>
>
> ************************ 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
> --
> To unsubscribe from this list: send the line "unsubscribe linux-c-programming" in
> the body of a message to majordomo@xxxxxxxxxxxxxxx
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
--
To unsubscribe from this list: send the line "unsubscribe linux-c-programming" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Assembler]     [Git]     [Kernel List]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [C Programming]     [Yosemite Campsites]     [Yosemite News]     [GCC Help]

  Powered by Linux