How do you use gdb?(你如何使用gdb?)
本文介绍了你如何使用gdb?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我决定了解我们的 C/C+ *nix 实践者如何使用 gdb 调试器.
I decided to find out how our C/C+ *nix practitioners use the gdb debugger.
这是我通常使用的:
- b - break filename.c:line #, function, filename.cpp:function, className::Member
- n, c, s -- 下一步继续
- gdb程序名=>设置断点==>运行[参数列表](我这样做是为了在程序启动前设置断点)
- l - 列出周围的源代码.
- 附加进程ID6 休息 [地点]
- gdb programName corefile.core(检查应用崩溃的原因)
- 我有时也会在退出函数(break exit)处设置断点来检查程序堆栈
- info b 检查所有断点
- 清除[断点列表]
你如何使用它?
推荐答案
我认为最有用的 gdb 命令(除了所有已经列出的):
Most useful gdb commands in my opinion (aside from all already listed):
- 线程信息 - 关于线程的信息
- 线程N - 切换到线程N
- catch throw - 中断任何抛出的异常.当您仅在堆栈展开后发现错误时很有用.
- printf,print - 检查所有表达式,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
最后,如果通过慢速链接进行调试,文本 UI 可能会派上用场.要使用它,请使用 --tui
命令行开关启动 gdb.
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?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
织梦狗教程
本文标题为:你如何使用gdb?


基础教程推荐
猜你喜欢
- 为什么 typeid.name() 使用 GCC 返回奇怪的字符以及如 2022-09-16
- 为什么 RegOpenKeyEx() 在 Vista 64 位上返回错误代码 2021-01-01
- 初始化列表*参数*评估顺序 2021-01-01
- 如果我为无符号变量分配负值会发生什么? 2022-01-01
- 我应该对 C++ 中的成员变量和函数参数使用相同的名称吗? 2021-01-01
- CString 到 char* 2021-01-01
- 非静态 const 成员,不能使用默认赋值运算符 2022-10-09
- 为什么派生模板类不能访问基模板类的标识符? 2021-01-01
- 通过引用传递 C++ 迭代器有什么问题? 2022-01-01
- GDB 显示调用堆栈上函数地址的当前编译二进制文 2022-09-05