gprof support

Asked by kean

So, I am working with the toolchain version 4.7-2014-q2 and I am trying to enable gprof profiling information (-pg flag).

I got semihosting to work, so that my instrumented bare-metal program should be able to write into the gmon.out file directly on the filesystem of my PC.

Unfortunately the linker complains about a missing __gnu_mcount_nc function and looks like I have to implement it on my own. The gprof documentation provided along with the toolchain says that __gnu_mcount_nc is an instrumentation routine which is called within any function of my program. __gnu_mcount_nc should simply retrieve the caller and callee program counters (basically the arc in the call graph) and then pass them to the function __mcount_internal. It looks easy enough, but my problem is that the __mcount_internal function is also not provided along with the toolchain. I objdumped and grepped all the libraries and object files, but I can't find any __mcount_internal symbol.

I am afraid that the current toolchain version doesn't provide the necessary profiling support yet and I have to implement it on my own (do the bookkeeping of the call graph's arc execution and at the end generate the gmon.out file with the right format). Note that this wouldn't provide any information about the time spent in the functions. Please tell me that I am wrong :-)

I also tried to build my program with the latest version of the toolchain (4.8-2014-q2), but it didn't work either. In this case gcc does something different: the linker tries to use a libc_p.a library (I guess it is a C library for profiling purpose), but she can't find it because it is not provided along with the toolchain.

Thank you in advance for your help
Kean

Question information

Language:
English Edit question
Status:
Solved
For:
GNU Arm Embedded Toolchain Edit question
Assignee:
No assignee Edit question
Solved by:
kean
Solved:
Last query:
Last reply:
Revision history for this message
Thomas Preud'homme (thomas-preudhomme) said :
#1

Hi Kean,

Unfortunately the reason is that newlib does not support profiling as of now. This explains the missing libc_p.a and probably the missing __mcount_internal.

Best regards.

Revision history for this message
kean (kean-mariotti) said :
#2

Hi Thomas

thank you for your answer.

Kean

Revision history for this message
Erich Styger (erich-styger) said :
#3

Hi Kean,
this is an old thread, but here is how I was able to get gprof profiling working with the GCC ARM Embedded:
http://mcuoneclipse.com/2015/08/23/tutorial-using-gnu-profiling-gprof-with-arm-cortex-m/

I hope this helps,
Erich