15.3.6 Example Stack Report

For this simple example, assumed to be stored in a file named test.c,
int max(int a, int b){
        if (a < b)
               return b;
        return a;
}
 
int main() {
        int a[10], i, j;
 
        for (i =0; i < 10; i++)
               a[i] = i;
        for (i = 0; i < 10; i++)
               a[i] = max(a[i], a[10-i/2]);
        return a[0];
}
when built with:
xc32-gcc -mprocessor=32MZ2048ECH100 -mchp-stack-usage -O0 mips_stack_guidance.c
the compiler will print the following stack-usage report.
============= STACK USAGE GUIDANCE =============
In the call graph beginning at _reset,
	104 bytes of stack are required.

However, the following cautions exists:

1. Indeterminate stack adjustment has been detected:
	_main_entry uses 104 bytes
	__pic32_software_reset uses 24 bytes
No stack usage predictions can be made.

2. The following functions cannot be connected to the main call graph.
This is usually caused by some indirection:
	__DbgExecReturn uses 24 bytes
	_bev_exception uses 48 bytes
	_gen_exception uses 136 bytes
	simple_tlb_refill_vector uses 136 bytes
	_cache_err_vector uses 136 bytes
	__pic32_size_cache uses 0 bytes
	_DefaultInterrupt uses 24 bytes
You must add stack allowances for those functions.
================================================