这是一篇由 Liam Huang 翻译的译文,原文是 Brendan Gregg 所作的 gdb Debugging Full Example (Tutorial): ncurses。转载请保留本段文字,尊重作者和译者的权益。
The author of this work is Brendan Gregg and this work was firstly posted on gdb Debugging Full Example (Tutorial): ncurses. This is the translation of the original work, by Liam Huang. Please keep this information at the very top of your reprint, for the rights of the author and the translator.
当我尝试在网上寻找「GDB 范例」时,我发现大多数文章只是贴出了命令,而没有讲解相关输出。GDB 是 GNU 调试器(GNU Debugger),亦是 Linux 系统上的标准调试器。在听 Greg Law 在 CppCon 2015 上关于 GDB 的演讲时(Give me 15 minutes and I'll change your view of GDB),我发现 Law 给出了相关输出,从而意识到了上述不足。
Law 的演讲,也让我意识到应该分享一个使用 GDB 解决问题的完整范例:包括命令输出、各个步骤,以及一些死胡同。也就是说,这篇文章将分享使用 GDB 调试查错的一般步骤,而不是其他特别的东西。这篇文章介绍了 GDB 的基本使用方法,因此可以作为教程使用。不过,还有很多东西没有介绍,请谨记在心。