Thanks to nettigo team for their article.
What is a debugger
The Arduino M0 Pro represents a simple, yet powerful, 32-bit extension of the Arduino UNO platform.
The board integrates an Atmel’s Embedded Debugger (EDBG) which provides a full debug interface with no need for additional hardware, making debugging much easier.
Debugger is a tool for control and analyze your program at runtime : you can going through your code step by step (by breakpoint or line) and know variables value at specific moment and inspect your sketch behavior/flow.
How it works
Let's see how ArduinoStudio works!
Connect your board to programming
With halt icon
you can stop sketch and analyze your environment :
to do this you had to set your breakpoints and step through them with .
You can analyze your sketch line by line using step
While stopped at a breakpoint you can see values of variables clicking
If you want, pressing will appear in the console a list of all breakpoints (in all project files)
OpenOCD (Open On-Chip Debugger) is an open source software that provides debugging, in-system programming and boundary-scan testing for embedded devices.
The OpenOCD can be used with the GDB over the gdbserver. But it needs certain settings to be made before OpenOCD works with the gdbserver.
After OpenOCD is launched it listens on ports 3333 and 4444 : the first port is a GDB server, the second one is a telnet server, we'll use the first one.
GNU Debugger is the most popular open source solution for debugging C/C++ programs.
GDB will be used to stop/restart execution, examine environments (stack, variables, etc. ), set breakpoints and others features.
We'll run GDB and then we'll tell it where find the running sketch, localhost:3333 (see above)