gdb 调试器最棘手/有用的命令
您可以在运行 gdb 或 dbx 等调试器时发布最棘手和最有用的命令吗?
Can you post your most tricky and useful commands while you run a debugger like gdb or dbx.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(12)
使用文本用户界面启动 gdb
Start gdb with a textual user interface
从 gdb 7.0 开始,有可逆调试,因此您最喜欢的新命令是:
Starting in gdb 7.0, there is reversible debugging, so your new favourite commands are:
您也可以在使用一段时间后通过键入“wh”切换到文本模式,而不是使用“-tui”参数启动 GDB。
Instead of launching GDB with "-tui" param you can also switch to text mode after a while using by typing "wh".
thread apply all bt
或thread apply all print $pc
:用于快速找出所有线程正在做什么。thread apply all bt
orthread apply all print $pc
: For finding out quickly what all threads are doing.例如 stl-views.gdb
For example the macros defined in stl-views.gdb
编写 gdb 脚本是一个好技巧,除此之外我还喜欢
设置调度程序锁定开/关,以防止在单步执行某个线程时运行其他线程。
scripting gdb is a good trick, other than that I like
set scheduler locking on / off to prevent the running of other threads when you are stepping in one.
启动 gdb 时使用
-command=<带有 gdb 命令的文件>
选项。与-x <命令文件>
相同。该命令文件可以包含断点、选项等 gdb 命令。在需要使用 gdb 连续调试运行特定可执行文件的情况下非常有用。Using the
-command=<file with gdb commands>
option while firing up gdb. Same as-x <command file>
. This command file can contain gdb commands like breakpoints, options, etc. Useful in case a particular executable needs to be put through successive debug runs using gdb.信息线程以列出所有活动线程,并且 f(#) ->; # 要切换到的线程号
有时我使用gdb从十六进制转换为十进制或二进制,它非常方便,而不是打开计算器
info threads to list all the active threads, and f(#) -> # thread number you want to switch to
sometime i use gdb to convert from hex to decimal or binary, its very handy instead of opening up a calculator
不要使用选项 -tui 启动 gdb 来查看包含突出显示程序中执行代码行位置的屏幕的子进程,而是使用 Cx o 和 Cx a 跳入和跳出此功能。如果您正在使用该功能以及暂时不使用该功能,那么这非常有用,以便您可以使用向上箭头获取上一个命令。
Instead of starting gdb with the option -tui to see a child process that contains a screen that highlights where the executing line of code is in your program, jump in and out of this feature with C-x o and C-x a. This is useful if you're using the feature and what to temporarily not use it so you can use the up-arrow to get a previous command.
这可能很有用,我相信它可以改进,欢迎帮助:
This can be useful, I am sure it could be improved though, help welcome:
要调试 STL,请将内容添加到 .gdbinit,请按照以下说明操作:
http://www .yolinux.com/TUTORIALS/GDB-Commands.html#STLDEREF
To debug STL, add content to .gdbinit, follow these instructions:
http://www.yolinux.com/TUTORIALS/GDB-Commands.html#STLDEREF