逐步查看代码

下表总结了您可以用来逐步检查代码和变量变化的函数。

按钮功能键盘快捷键说明
停止调试器Stop DebuggerShift+F5停止调试器。
跨过Step OverF10macOS 上为Command+Shift+O)跳转到正在调试的函数中的下一行。它将执行调用并移动到函数中要执行的下一行。
走进Step IntoF11在 macOS 上为Command+Shift+I)进入当前所在行。对于函数调用,则进入函数并准备继续。
走出去Step OutShift+F11macOS 上为Command+Shift+T)完成函数执行,并退出到调用它的函数。
Run to LineCtrl+F10macOS 上为Shift+F8)运行到光标所在行。

你也可以直接跳转到某一行,而不是执行到该行结束,以避免变量被修改或函数被调用等。

Run to Selected FunctionCtrl+F6在进入嵌套函数时,运行到所选函数。
继续ContinueF5从上次停止的地址重新开始执行程序。

压缩 GDB 中的步骤

使用 GDB 作为调试后端时,可以将多个步骤压缩为一个步骤,以减少调试噪音。更多信息,请参阅GDB

扩展的 GDB 设置有在代码中后退一步的选项,但应谨慎使用该选项,因为它在 GDB 端速度较慢且不稳定。更多信息,请参阅GDB

在 macOS 中进入框架

在 macOS 中,外部库通常内置于所谓的框架(Frameworks)中,其中可能包含发布和调试版本的库。在 macOS 桌面上运行应用程序时,默认使用 Frameworks 的发布版本。要进入 Frameworks,请在项目运行设置中选择Use debug versions of Frameworks 选项。

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

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.