添加断点

要添加断点:

  1. 可通过以下任一方式添加新断点:
    • 在代码编辑器中,单击左侧边距,或在希望应用程序暂停的特定行上按F9 键(macOS 上为F8 键)。
    • 在“Breakpoint Preset ”视图或“Breakpoints ”视图中:
      • 双击视图中的空白区域。

        “断点预设”视图

      • 右键单击视图,并在上下文菜单中选择“Add Breakpoint ”。
  2. 在“Breakpoint type ”中,选择应用程序代码中希望应用程序暂停的位置。

    “添加断点”对话框

清除“Enabled ”选项,可使断点暂时失效(如同已将其删除),但会保留有关该断点的信息,以便您稍后再次启用它。

其他需要指定的选项取决于您选择的位置,例如文件名和行号、地址、表达式或函数名。下表总结了高级选项。

选项
Condition如果在条件评估结果为true 时,在应用程序在断点处停止之前要评估的条件。
Ignore count在应用程序停止之前忽略该断点的次数。
Thread specification
Path确定设置断点时如何指定路径:
  • Use Engine Default 是调试器引擎的首选设置。
  • Use Full Path 传递完整路径,以避免多个模块中存在同名文件时产生的歧义。这是 CDB 和 LLDB 引擎的默认设置。
  • Use File Name 仅传递文件名。当源代码树的位置与构建模块时所用的位置不一致时,此设置非常有用。这是 GDB 的引擎默认设置,因为在 GDB 中使用完整路径可能会导致速度变慢。
Module为函数或文件类型断点指定模块(库或可执行文件的基名),以加快调试器启动速度(CDB、LLDB)。
Commands应用程序暂停时要执行的命令。每行列出一个命令。GDB 将按您指定的顺序执行这些命令。
Tracepoint only跟踪点可让您在无需添加日志语句或修改代码的情况下记录应用程序信息。您可以为跟踪点设置条件。
Message要在“应用程序输出”中显示的跟踪点消息。

另请参阅 《如何:调试》、《调试》、《调试器》和《设置断点》。

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.