-finstrument-function -O2 and printf() instrumentation

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

 



Hi all,

I'm just playing arounnd with instrumenting source code using
-finstrument-function compiler switch. I noticed the following behaviour
within gcc (Ubuntu 4.8.4-2ubuntu1~14.04) 4.8.4:

If I compile a simple C program using printf() calls without
optimization the printf() calls are not instrumented. But if I compile
the simple C program with -O2 the instrumentation functions are also
called for any printf() call.

However if I look into the object file using nm there is only an U
reference to printf():

nm ./ComplexChain-ComplexChain.o
                 U __cyg_profile_func_enter
                 U __cyg_profile_func_exit
0000000000000000 d _init.4299
0000000000000000 r .LC0
0000000000000000 T main
00000000000003a0 T Main
                 U printf
                 U __printf_chk
                 U strtol
0000000000000110 T SubTran1
00000000000000c0 T SubTran2
                 U time
                 U usleep

Any idea why func_enter and func_exit are called for printf() if
compiled with -O2? Is the printf() call somehow inlined with -O2?

Regards,
Stefan



[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux