I have a gprof "flat profile" output which lists all my functions, including static functions. But, the "calls", "self ms/call", and "total ms/call" columns are all empty for the functions declared as "static". I want to see the data for these functions as well; they are actually far more interesting to me than the public functions in the module. For example:
% cumulative self self total
time seconds seconds calls ms/call ms/call name
55.32 3.38 3.38 Static_Func1
16.61 4.39 1.01 Static_Func2
12.44 5.16 0.76 2 380.00 380.00 Public_Func1
9.90 5.76 0.60 Static_Func3
2.78 5.93 0.17 Static_Func4
0.98 5.99 0.06 12463589 0.00 0.00 main
0.65 6.03 0.04 1200000 0.00 0.00 Public_Func2
0.33 6.05 0.02 2 10.00 10.00 Public_Func3
0.33 6.07 0.02 Static_Func5
0.33 6.09 0.02 free
0.33 6.11 0.02 malloc
0.00 6.11 0.00 1 0.00 0.00 Public_Func4
I found Why does gprof occasionally not print number of calls for particular functions? which explains why I don't see the output for these functions, but is there a way to see it anyway aside from stripping out the static declarations? I know I can suppress printing static functions with -a
but I want to do the opposite and don't see an option for it.
When I edit the code to strip out the "static" keyword from the static functions in the above profile, the "calls" for main becomes empty (I'd expect 1, so it's wrong either way). More usefully, not only are the fields populated, but any functions called by those static functions also get listed. I'd like to be able to do that without any code changes.
I also found Is GNU gprof buggy? which seems to suffer from the same problems, but the solution there was to edit the code to force the compiler not to inline some of the functions. I don't want to edit my code just for the sake of profiling, I want to be able to see all my functions as they exist now.
Version info, running in MinGW shell under Windows 7 64-bit:
$ which gprof
/mingw/bin/gprof.exe
$ gprof --version
GNU gprof (GNU Binutils) 2.22
Based on BSD gprof, copyright 1983 Regents of the University of California.
This program is free software. This program has absolutely no warranty.
binutils
/gprof
package. What platform are your running on? I'm experiencing a very similar behavior on mywindows 7
/cygwin
(32 bits) ... – dragosht