5.2.11 Function profiling

The compiler can generate function registration code for the MPLAB REAL ICE In-Circuit Emulator to provide function profiling. To obtain profiling results, you must also use a Power Monitor Board and MPLAB X IDE and power monitor plugin that support code profiling for the MPLAB XC8 C Compiler.

The -finstrument-functions option (see 4.6.5.1 Instrument Functions Option) enables this feature and inserts assembly code into the prologue and epilogue of each function. This code communicates runtime information to the debugger to signal when a function is being entered and when it exits. This information, along with further measurements made by a Microchip Power Monitor Board, can determine how much energy each function is using. This feature is transparent, but note the following points when profiling is enabled:

• The program will increase in size and run slower due to the profiling code

• One extra level of hardware stack is used

• Some additional RAM memory is consumed

• Inlining of functions will not take place for any profiled function

If a function cannot be profiled (due to hardware stack constraints) but is qualified inline, the compiler might inline the function. See 5.8.1.2 Inline Specifier for more information on inlining functions.