-
Notifications
You must be signed in to change notification settings - Fork 77
Debugging sketches
You have written a sketch and it is not working as you hoped it would. What are you to do now? One option is to perform debugging using a symbolic debugger. This is a program that allows you to step through the source code of your sketch line by line seeing the order in which things execute and the value of variables in effect. We can do this using the RaspPiArduino environment.
Raspbian has a command line debugger called gdb
. Much has been written about this tool. If you are a command line fan, this likely all you need. However, since debugging is inherently graphical ... in that I want to see the source line my program is currently executing, we really want to use a more sophisticated environment. The packaged called "ddd" does just that for us. This package provides an X-Windows based UI in front of gdb. We will assume you have that installed and will be using it.
In order to debug your Arduino sketches, you will need to change how you prepare and deploy your solutions.
First, the source code has to be compiled with the -g
flag which causes the inclusion of diagnostic materials into the final executable.
Second, at runtime, the source of the sketch must be in the same directory as the executable you are debugging.