GDB

要指定管理 GDB 进程的首选项,请转到首选项>Debugger >GDB

调试器首选项中的 GDB 选项卡

下表概述了首选项。

首选项
GDB timeout终止无响应 GDB 进程的超时(秒) 默认值为 40 秒,对于大多数应用程序来说足够了,但如果在速度较慢的机器上加载大型库或列出源文件所需的时间比这长得多,则应增加该值。
Skip known frames when stepping将多个步骤压缩为一步,以减少步入代码时的调试噪音。例如,跳过原子引用计数代码,信号发射的单步输入直接在与其相连的插槽中结束。
Show a message box when receiving a signal在调试过程中,一旦应用程序接收到信号(如 SIGSEGV),就会显示一个消息框。
Adjust breakpoint locationsGDB 允许在未生成代码的源代码行上设置断点。在这种情况下,断点会被转移到实际生成代码的下一行源代码上。要通过移动源代码编辑器中的断点标记来反映这种临时变化,请选择该复选框。
Use dynamic object type for display显示对象的动态类型还是静态类型。选择动态类型可能会降低调试速度。
Load .gdbinit file on startup在调试器启动时读取用户默认的 .gdbinit 文件。
Load system GDB pretty printers使用计算机上安装的默认 GDB pretty 打印机,或链接到应用程序使用的库。
Use Intel style disassembly将默认的 AT&T 风格反汇编转换为英特尔风格。
Use automatic symbol cache自动将 GDB 符号索引的副本保存在磁盘缓存中,并在将来加载相同二进制文件时从缓存中获取。
Use debug info daemon尝试自动获取系统包的调试信息。

执行附加命令

要在 GDB 启动之后、调试程序启动或连接之前以及调试辅助程序初始化之前执行 GDB 命令,请在Additional Startup Commands 中输入这些命令。

要在 GDB 成功连接到远程目标之后执行 GDB 命令,请在Additional Attach Commands 中输入这些命令。可以在此处添加进一步设置目标的命令,如monitor resetload

要执行简单的 Python 命令,请在命令前加上python 。要执行跨多行的 Python 命令序列,可在单独一行中以python 作为块的前缀,并在单独一行中追加end 。要执行任意 Python 脚本,请使用python execfile('/path/to/script.py')

扩展 GDB 首选项

Extended 组中的首选项可以访问 GDB 的高级或实验功能。启用它们可能会对调试体验产生负面影响,因此请谨慎使用。

首选项
Use asynchronous mode to control the debugged process在后台(异步)模式下执行命令。当程序运行时,GDB 会立即打开一个命令提示符,你可以在此发出其他命令。
Use common locations for debug information启动 GDB 时,添加调试信息位置的常用路径,如/usr/src/debug
Stop when qWarning() is called在每个qWarning() 函数上添加一个断点。
Stop when qFatal() is called在每个qFatal() 函数上添加一个断点。
Stop when abort() is called在每个abort() 函数上添加一个断点。
Enable reverse debugging启用后退功能。该功能在 GDB 端非常缓慢且不稳定。当在系统调用上倒退时,它会表现出不可预测的行为,并且很可能会破坏你的调试会话。
Debug all child processes在分叉后继续调试所有子进程。

另请参阅 如何:调试调试调试器调试器

Copyright © The Qt Company Ltd. and other contributors. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.