Quantcast
Channel:
Viewing all articles
Browse latest Browse all 59170

Forum Post: RE: Stack Analysis and Debugging

$
0
0
Each Thread has it's own stack, the size is set in the configuration (and the default thread stack size is 1024 bytes) :- At a context switch the size of the thread stack is set in the stack monitor. If the thread stack goes outside the allocated memory range, the NMI will trigger. What can happen, is that if you use alot of local variables in the thread code, these local variables are created on the thread stack, causing the Stack monitor to trigger. If you set a break point in the NMI handler for the Stack monitor, then look in the RTOS view, you can see the Thread that is in a running state when the stack monitor triggers, then check the stack size, and the local variables used in that stack:- In my examle, the code in New Thread is :- /* New Thread entry function */ void new_thread_entry(void) { #ifdef TEST_NMI     uint32_t test[256];     /* This thread only has a 1024 byte stack, so this will cause the HW stack monitor to */     /* Generate an NMI, optimisation is set to -O0  */     test[127] = 0xffffffff; --------- Since I only have a 1024 byte stack, creating a local variable that is too big has caused the stack monitor to trigger. So, it might be worth checking this point.

Viewing all articles
Browse latest Browse all 59170

Trending Articles