如何使用gdb的? [英] How do you use gdb?

查看:95
本文介绍了如何使用gdb的?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我决定找出我们的C / C + * nix的从业者如何使用gdb调试。

I decided to find out how our C/C+ *nix practitioners use the gdb debugger.

下面是我通常使用:


  1. B - 休息FILENAME.C:行号,功能,filename.cpp:函数,类名::成员

  2. N,C,S - 接下来继续步

  3. 的gdb程序名称=>设置断点==>运行[参数列表](我这样做是为了设置断点在程序启动前)

  4. L - 列出周围的源$ C ​​$ C

  5. 附加进程ID
    6次破[位置]

  6. GDB PROGRAMNAME corefile.core(检查为什么应用崩溃)

  7. 我有时也设置断点在退出函数(中断退出)审查程序堆栈

  8. 信息B检查所有断点

  9. 清除[断点列表]

你如何使用它?

推荐答案

最有用的gdb命令在我看来,(除了所有已上市):

Most useful gdb commands in my opinion (aside from all already listed):


  • 信息线程 - 关于线程的信息

  • 线程的 N - 切换到线程的 N

  • 抓扔 - 在任何抛出的异常休息。有用的,当你抓住堆栈解开后,才错误。

  • 的printf 打印 - 检查任何和所有前pressions,printf的接受C风格的格式符

  • info threads - information about threads
  • thread N - switch to thread N
  • catch throw - break on any thrown exception. Useful when you caught the bug only after the stack unwound.
  • printf,print - examine any and all expressions, printf accepts C-style formatting specifiers

最后,如果调试通过慢速链接,文本用户界面可能使用。要使用它,开始用gdb的 - TUI 命令行开关

Finally, if debugging over a slow link, the text UI might be of use. To use it, start gdb with the --tui command-line switch.

这篇关于如何使用gdb的?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆