I have a pretty large code and sometimes my code jump to first line main.c and SRAM is empty at that moment but all ports and periphery are still configured. The optimization seems help, but the problem occurs in any time, it could work for days without problem or the problem could appear after 10 minutes. I tried to change size of the buffers but it seems its not helping.
How to find that bug?
UPDATE: I've found my bug, it wasn't a bug actually. I made a lot of changes for code optimization and it seems now I don't have stackoverflow.
the problem was that I have 6 spi devices, 2 gprs modules, several sensors, external flash memory, USB-cdc, so xmega stack was overloaded when I was getting too much data. So I don't know now what is the better option for me: moving form xmega to more powerful mcu or leave it on xmega and hope for the best.
Thank you guys for your help, especially
2. Also thanks gchapman for idea about static code analysis Cppcheck found some bad moves. And I've never used data breakpoints before, with the canary algorithm it helped me a lot