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?
基础教程推荐
猜你喜欢
- 运算符重载的基本规则和习语是什么? 2022-10-31
- 什么是T&&(双与号)在 C++11 中是什么意思? 2022-11-04
- 调用std::Package_TASK::Get_Future()时可能出现争用情况 2022-12-17
- C++ 标准:取消引用 NULL 指针以获取引用? 2021-01-01
- 如何定义双括号/双迭代器运算符,类似于向量的向量? 2022-01-01
- 您如何将 CreateThread 用于属于类成员的函数? 2021-01-01
- C++,'if' 表达式中的变量声明 2021-01-01
- 设计字符串本地化的最佳方法 2022-01-01
- C++ 程序在执行 std::string 分配时总是崩溃 2022-01-01
- 如何在 C++ 中处理或避免堆栈溢出 2022-01-01