-pg profiling instrumentation question

Juan Carlos Franzoy jfranzoy@yahoo.com.ar
Thu Jan 24 15:10:00 GMT 2008

Hello. I have already post this message on a gcc mailing list. I was told to post it here.

I am having problems profiling an application. I think the problem is that one of our libraries break -pg instrumentation. This library hide portabilities issues under a portable interface, allowing us to run in console mode, in daemon mode  in unices or as a service in windows. As you may guess, it is a complex library that do a lot of things. I do not know which of these may be hurting -pg.

This pseudocode is a description of what I am doing.

void a() {}
void b() { for(int i=0; i < 10000; ++i) a(); }
void f() {}
void g() { for(int i=0; i < 10000; ++i) f(); }

class MyModule() ... {
    void operator()() {
         // *2
         for(int i=0; i < 10000; ++i) g();
} myModule( .... );

int main() {
   // *1
   for(int i=0; i < 10000; ++i) b();
   mylib::run(); // create a thread per module

The problem is that the profiling information contain time information for b() and a() but no for g() and f(). On the other hand the call count is the same. 

--- gprof output ---
Flat profile:
Each sample counts as 0.01 seconds.
   %     self                           self          total
 time  seconds    calls         ms/call  ms/call  name
50.00    0.22     10000            0.02     0.04         a()
29.55    0.13    100000000     0.00     0.00         b()
20.45    0.09    1                 90.00   90.00       _static_init
 0.00      0.00    100000000    0.00     0.00        f()
 0.00      0.00     10000            0.00     0.00        g()
--- end of gprof output ---

Note: I already try making a sigprocmask, pthread_mask to unblock SIGPROF in *1 and *2. I also verifíed that the signal handler of SIGPROF is the same in *1 and *2, it is a valid pointer, not SIG_DFL nor SIG_IGN. I also tried to add a call to moncontrol(1) in *2. This seems to work, at least it displays something != 0 in %time column.

If somebody can help will make me happy. Thanks.

Juan Carlos.

      Tarjeta de crédito Yahoo! de Banco Supervielle.
Solicitá tu nueva Tarjeta de crédito. De tu PC directo a tu casa. www.tuprimeratarjeta.com.ar

More information about the Binutils mailing list