本页内容

逐步执行代码

下表总结了可用于逐步执行代码并检查变量变化的功能。

按钮功能键盘快捷键说明
停止调试器Stop DebuggerShift+F5停止调试器。
跨过去Step OverF10(macOS 上为Command+Shift+O在正在调试的函数内逐步执行下一行代码。它会执行该调用,并跳转到函数中待执行的下一行。
踏入Step IntoF11(macOS 上为Command+Shift+I步入当前所在的代码行。如果是函数调用,则进入该函数并准备继续执行。
迈出一步Step OutShift+F11(macOS 上为Command+Shift+T完成函数的执行,并返回至调用该函数的函数。
Run to LineCtrl+F10(macOS 上为Shift+F8运行至光标所在的行。

您还可以直接跳转到某一行,而不是执行到该行的末尾,例如,以此避免变量被修改或函数被调用。

Run to Selected FunctionCtrl+F6当您逐步进入嵌套函数时,跳转至所选函数。
继续ContinueF5从上次停止的地址恢复应用程序的执行。

在 GDB 中压缩调试步骤

当使用 GDB 作为调试后端时,您可以将多个步骤压缩为一个步骤,以减少调试过程中的干扰。有关详细信息,请参阅GDB

扩展的 GDB 设置中包含“向后步进”选项,但请谨慎使用此选项,因为在 GDB 端该操作速度较慢且不稳定。有关更多信息,请参阅GDB

在 macOS 中步入框架

在 macOS 中,外部库通常被构建到所谓的“框架”(Frameworks)中,这些框架可能同时包含库的发布版和调试版。当您在 macOS 桌面上运行应用程序时,默认使用的是框架的发布版。若要步入框架,请在项目运行设置中选择“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.