Debugging is crucial to successful software development, but even many experienced programmers find it challenging. Sophisticated debugging tools are available, yet it may be difficult to determine which features are useful in which situations. The Art of Debugging is your guide to making the debugging process more efficient and effective.
The Art of Debugging illustrates the use three of the most popular debugging tools on Linux/Unix platforms: GDB, DDD, and Eclipse. The text-command based GDB (the GNU Project Debugger) is included with most distributions. DDD is a popular GUI front end for GDB, while Eclipse provides a complete integrated development environment.
In addition to offering specific advice for debugging with each tool, authors Norm Matloff and Pete Salzman cover general strategies for improving the process of finding and fixing coding errors, including how to:
Inspect variables and data structures Understand segmentation faults and core dumps Know why your program crashes or throws exceptions Use features like catchpoints, convenience variables, and artificial arrays Avoid common debugging pitfalls Real world examples of coding errors help to clarify the authors' guiding principles, and coverage of complex topics like thread, client-server, GUI, and parallel programming debugging will make you even more proficient. You'll also learn how to prevent errors in the first place with text editors, compilers, error reporting, and static code checkers.
Whether you dread the thought of debugging your programs or simply want to improve your current debugging efforts, you'll find a valuable ally in The Art of Debugging.
A must-read for every software developer. Debugging is a sure way to make your life easier if you understand what you're doing.
The art Art of Debugging is focusing specifically on the most popular debugging tool - gdb while providing code examples in C/C++. The debugging scenarios handle even the most situations (crashes, threads and networking).
The other tools mentioned are DDD and Eclipse, but in my opinion they're rightfully with lesser focus. GDB is the real gem that needs a lot of learning and practice to master.
A bit old, many commands will have to be adjusted to run properly (about 50%). Some libraries have changed their names so try to search up on StackOverflow for better-updated information..
Still a very helpful book overall! Would recommend!
* Похоже на очень сильно растянутый tutorial. Поначалу кажется, что всё полезное в книжке можно было бы уместить на лист A4. Ну или на два. * Примеры старые. Т.е. если взять более-менее актуальную версию Ubuntu + gdb, то вывод в примерах будет выглядеть по-другому. И вести себя приложения уже будут по-другому. Это делает чтение не очень удобным. * Код примеров страшненький. Некоторые примеры открываешь и баги видно прямо тут же. Автор рассказывает, насколько он быстрее найдёт баг с помощью gdb по сравнению с отладкой printf-ами. А если бы он в код заглянул, то для трёх багов из четырёх не пришлось бы даже компилировать. * Совершенно ненужные куски про Eclipse и почти ненужные про DDD (зато с картинками, которые объём книги раза в полтора увеличивают).
С другой стороны, когда дочитал и стал просматривать, то оказалось, что всё не совсем плохо:
* Есть некоторая системность -- достаточно подробно рассказывается, откуда берутся segmentation fault или проблемы в многопоточном коде. И уже потом, как их отлаживать. * По результатам примеров я примерно осознал, как работать с gdb. Не могу сказать, что стало прям удобно-удобно, но часть возникших рабочих задач я решал уже с помощью lldb, а не с помощью вывода в лог. Не уверен, что результат я получил быстрее, но дополнительный инструмент это всегда хорошо. * Рассматриваются разные реальные ситуации при отладке: - отладка приложений, которые много пишут в поток вывода (или, как в книге, curses-приложения, которым нужен отдельный терминал) - использование инструментов типа strace, ltrace или mcheck/mtrace для отлова странных ошибок и проездов по памяти - работа с другими языками из DDD
Тем не менее, рекомендовать не готов. Tutorial по gdb можно найти и покороче.
The book claims to be about GDB, DDD, and Eclipse but really GDB is the star of the show, DDD gets some references, and Eclipse feels like it was possibly included as an afterthought because the publisher insisted on it. The book is clearly aimed at the sort of person writing code in Linux using vim, which is fine for me. :D Historically I've been a trace debugger but until reading this book I hadn't realised the power of GDB and it has definitely convinced me to start using it in the future! It as had a useful chapter near the end suggesting other tools but with the glaring omission of valgrind.
If you're new to c/c++ debugging and want to learn more on gdb, this book is for you. Currently, i'm reading this book (218 of 372 pages) and i think this book worth the time, it takes. Each chapter focus on some aspect of debugging/diagnosing and give the reader insights, tricks and examples of effective usage.