I need to do a run-time stack analysis on embedded hardware to ensure I've allocated enough stack space. I understand the basic theory. On boot, you initialize the stack with a known pattern (such as all 0xFF or 0xAA), then allow your program to run. As it runs the stack grows and shrinks but it never restores the original pattern. After a sufficiently long enough period, examine the stack and find the address of the last stack value to be altered.
I do not need a portable solution, just a solution for the dsPIC33EP512MU810 and PIC32MX795F512. My fallback plan is to incrementally decrease the stack size until I get a stack overflow, but that only works once I have a release candidate, I'd much prefer a solution that continually monitors throughout development and production.