📅 2015-Apr-25 ⬩ ✍️ Ashwin Nanjappa ⬩ 🏷️ book, gdb ⬩ 📚 Archive
I picked up The Art of Debugging with GDB, DDD and Eclipse primarily to learn how to use GDB. Debuggers are one of my favorite tools and I have fond memories of them. The very first debugger I used was the fabulous graphical debugger built into Turbo C++. I can still remember doing rudimentary debugging in it when I wrote my first editor. After that came the awesome Visual C++ 6 and from that time to now, it is the beautiful graphical debugger that I believe is the killer feature of Visual Studio. But working on Linux, not being able to use a non-graphical debugger like GDB quickly becomes a weakness. Inserting printf into code can turn painful pretty quickly.
This book tackles two objectives: to teach you how to debug a problem and also introduces you to use the specific tools to do it: GDB, DDD or Eclipse, whichever is your poison. I completely skipped the DDD and Eclipse sections, since using those graphical debuggers are quite straightforward anyway. This book is a great introduction to GDB. Using many simple, bug-filled programs as examples, it shows how to run GDB, put breakpoints, print variables, write your own functions and debug core dumps. The chapter on virtual memory and investigating segmentation faults is probably the crown jewel of the book. In addition, it scratches the surface of debugging networking and multi-threaded programs. Quite strangely, the last few chapters also deal with odds and ends like compilation and linking errors, trace tools and lint tools!
If GDB seems intimidating, I can highly recommend this book for you. Using some great examples, it helps you understand how to dissect using GDB and find the bug. Another good aspect of the book is it shows you how these experts actually use these tools in their daily work. Instead of spending chapters on non-debugging tools, I wished the authors had demonstrated more cool scenarios of using GDB: programs with no debug symbols, debugging running programs, debugging embedded devices over JTAG or other interfaces, working with disassembly and more information on the TUI inside GDB. These authors have a great writing style and I hope they will cover these other scenarios in their next edition. After all, there are no other books on GDB!
PS: It looks like all the GDB bits of this book have been updated and maintained as a GDB Tutorial online.