Short Stack info macro
Posted: Wed Jan 14, 2015 1:21 pm
Here's a short little Stack info macro I wrote while working on TLS. It requires that Stack checking is turned on in UCOS.
It reports,
-Dan
It reports,
- Top of current stack
- Current stack pointer
- Space remaining in stack
- Bottom of the stack
Code: Select all
#include <ucos.h>
char * GetSP_ext()
{
asm( ".global GetSP");
asm( "GetSP:");
asm( " move.l %sp, %d0");
asm( " rts");
}
#define SHOW_STACK_DEPTH() \
{\
iprintf("Stack at line %d of file %s.\n", __LINE__, __FILE__);\
iprintf("Top -- Current -- Rem -- Bottom\n%p -- %p -- %7d-- %p\n", \
OSTCBCur->OSTCBStkTop, GetSP(), GetSP() - (char *)OSTCBCur->OSTCBStkBot, OSTCBCur->OSTCBStkBot);\
}