0

I have gprof working fine on a linux system. I am getting samples and also some call count information. So I added the attribute ((hot)) to some functions. Now they have disapeared from the gprof sample output, only my none hot functions are "sampled". The hot functions still appear in the call count information. How do I fix this ?

I suspect one of two things has happened. gprof filters on what it thinks is relevent addresses and the hot functions are now outside this range as they are now in the .text.hot section. Or, somehow, there is some confusion in the debug data for the hot functions and so gprof is ignoring them.

  • Have you looked at the assembly output (gcc option -S)? Is the debug info in the text.hot section somehow different or missing? – Chris Aug 14 '13 at 11:08
  • I've tried to reproduce this using the normal gcc toolchain in Fedora 19, and attribute((hot)) does not change the gprof behavior in any way. Could you post details of your toolchain and also the flags you use to compile the program? – Chris Aug 15 '13 at 08:20

1 Answers1

1

attribute((hot)) also makes it more likely that the functions are inlined, at least within the same source file. Call counts would only be increased if the non-inlined version of the function is called (probably from a different module). The functions would not show up in the samples, because only the call sites are known to the profiler.

You should be able to detect if this happened by checking your call counts. If they are much lower with attribute((hot)), inlining would be the cause.

Chris
  • 4,133
  • 30
  • 38
  • Thanks for this idea. I have looked at the map file and I can see instances in the .text.hot section. Also I have a tool that will display hot "lines". If the functions are inlined they would have disapeared from the "hot functions" list but the lines would still be hot. So it looks likes the stats are completely missing for the functions. I can also drill into "functions" and often find "lines" of code belonging to inlined functions. This is not happening. The samples are missing from the stats. :( – William J Bagshaw Aug 14 '13 at 10:48