for the first time in many years of coding I finally found a situation that I really need to debug my code properly. Before today I always did debugging by adding dozens of additional Serial.print() in code to see where it crashes and always found a proble quite fast. I know that is quite stupid solution, but its quite always fast deployable.
Anyway right now I have a SAMD21G board (Arduino MKR Zero) with "quite" stable code that crashes in very unpredictable manner - once in 30 minutes, next time in several hours, next time in less than minute... In this case above "debugging" method does not work, since it seems that my code is simply stuck after my periodically run interrupt code is executed and it looks like it never returns back to loop.
So I have access to Atmel ICE programmer/debugger at work, as I read it should be possible to use it as debugger too.
I never debugged a code on MCU (only some code log time ago on x86 Linux), so I would like to know some basics on debugging on ARM that I did not find online.
1.) I assume that Atmel ICE can be used for debugging in combination with openocd and gdb?
2.) How can I compile & upload sketch from Arduino IDE with debugging symbols? I guess that without them any debugging would be useless...
3.) What kind of output can I get from debugger on such hardware? I can I just leave debugger connected for several hours and after crash just read in which function in crashed?
Any recommende additional resources for debugging basics/tutorials would be greatly appreciated!