3.5.12 How Can I Find Stack Usage Information For Each Function of My Program?
The compiler's stack guidance feature analyzes your program and reports on the estimated maximum depth of any stack that has been used. If you need stack depth information displayed individually for each function in your program, you will need to perform an additional step after you build.
Use the MPLAB XC32 -mchp-stack-usage
option when you build your program.
Then use the xc32-objdump
utility and its -D
option
with the object file containing the functions whose stack depth is required. You might
need to use the compiler's -save-temps
option when you build the
project so that the object files needed for this utility are not deleted after
compilation.
xc32-gcc -mprocessor=32MZ2048ECH100 -save-temps -mchp-stack-usage main.c init.c
xc32-objdump -D main.o
The output of xc32-objdump
utility
might show you something similar to the
following.XC32 stack usage information:
<func1>:
used_stack: 0x70
flags: 0x0
kind: STATIC
<main>:
used_stack: 0x8
flags: 0x0
kind: STATIC
XC32 Stack Usage Version: 0x1