We have detected your current browser version is not the latest one. Xilinx.com uses the latest web technologies to bring you the best online experience possible. Please upgrade to a Xilinx.com supported browser:Chrome, Firefox, Internet Explorer 11, Safari. Thank you!

Showing results for 
Search instead for 
Did you mean: 
Visitor vgimonkar
Registered: ‎07-06-2018

Debugging Microblaze for stack overflow


I am running a program on microblaze and I suspect that my stack is getting overflowed causing a crash in microblaze.

While building the microblaze we didnt add any exception flags and also we dont have access to printf.

The way I am debugging this crash is getting the stack pointer from via register int *stack_ptr asm("r1");

and from a MAP file generated while building the microblaze, I get the stack start address. 

eg: .stack          0x00008c50      0x400

I know the stack end address based on the size of the stack. So stackSize/4 gives me the total pointers it can store.

I am calculating the percentageStackUsed = ((float)((void *)stack_ptr - (void*)stackStartAddr)*(stackSize/4))*100;

I am passing this variable percentageStackUsed to a common location were we can read out the number every other second. But I am not seeing any reasonable values.

I am not sure if this is a correct way to debug stackOverflow in microblaze. If this community has some suggestions please let me know

Tags (2)
0 Kudos