A Debugger is a program that is used for test and debug other programs. Debuggers provide information about what is happening inside a program during execution or before it crashes. Using a debugger, one can execute a program step by step in order to observe how the variables inside the program are changed in the shadow of each instruction or function.
Debuggers are shipped alone, like GNU Project Debugger (GDB) [2] and LLDB [3], or integrated with an IDE, like Visual Studio [4] and Eclipse [5]. The rest of the tutorial shows the basic instructions to work with GDB and Visual Studio. Since the concept of debugging instructions is similar in all debuggers, what is presented here can be applied in other debugger with slight changes. For example, [6] shows the counterpart of each GDB instruction in LLDB.
In the following paragraphs, we will look at how to 1. prepare the debugging tool; 2. insert and remove breakpoints; 3. monitore and change variables; 4. navigate through program statements; and 5. watch variables’ values. In each case, we will look at both GDB and Visual Studio.