A GNU Debugger, originally created by Richard Stallman in 1986, is a standard debugger for the GNU operating system and an essential tool for software developers. Being a portable application, it is widely used on many Unix-like operating systems as well. In this article I’ll show some basic commands and techniques for debugging software with GDB. I’ll be using GDB version 7.9 under Arch Linux on x86-64, unless noted otherwise. Source code for this article is available on my GitHub site.
Although there are many great tools to debug memory allocation errors, like Valgrind or Electric Fence, sometimes these tools aren’t available or it’s not feasible to use them. In this post I want to show you a debugging technique that doesn’t require any other software beside GNU C library. All of the examples were created and ran on a standard x86-64 machine.