Installing GDB and Valgrind
GDB and Valgrind are two useful debugging tools that we'll use later on in this book.
GDB is the GNU debugger, a tool that we can use to step through a program and see what's happening inside it. We can watch over variables, see how they change during runtime, set breakpoints where we want the program to pause, and even change variables. Bugs are inevitable, but with GDB, we can find these bugs.
Valgrind is also a tool we can use to find bugs, though it was made explicitly for finding memory leaks. Memory leaks can be challenging to find without a program such as Valgrind. Your program might work as expected for weeks, but then suddenly, things may start to go wrong. That's probably a memory leak.
Knowing how to use these tools will make you a better developer and your programs more secure.
Getting ready
Since we will be installing software here as well, we'll need to execute these commands with root privileges. If our...