In this module we have a brief look at (probably) the most important stage in the development cycle: debugging.

Print statements

The first and foremost debugging technique is simply outputting the values of the variables in the region where the error occurs. This allows you to “see” what the program is doing to the variable and (hopefully) spot the error. This seemingly stupid “technique” is almost always the best first step in trying to debug a problem.


Most programming languages also provide a way of imposing so-called assertions (or asserts for short). See for instance the implementation in Python or in C++. These are expressions that we require to be true. If a certain assertion turns out to be false, the program will (usually) terminate with an error. See the language specific implementations above for further details.

Debugging tools

Alternatively, there are also dedicated tools that can help you debug a piece of code. The most popular free and open-source debugger is gdb. This tool allows you to see what is going on inside the program at the moment it crashes.

For specific problems regarding memory usage, for instance to detect memory leaks, there are also specialised tool such as valgrind.

Finally there are also some proprietary tools such as for instance DDT, which is part of ARM Forge. These are often very expensive, but can be very helpful if they happen to be available on your system.