使用 CDB 进行远程调试

如果您的远程机器或容器运行的是 Windows 系统,且您的应用程序是使用 MSVC 编译的,则可以使用 CDB 进行远程调试。

如果已配置应用程序的远程执行功能,且通过单击“Run ”按钮(或按Ctrl+R)可正常运行,则可通过单击“Debug ”按钮(或按F5)启动远程调试。

在远程模式下,本地 CDB 进程与运行在远程机器上的 CDB 进程进行通信。该进程通过特殊的命令行选项启动,这些选项将其切换为服务器模式。远程 CDB 进程必须加载随Qt Creator 一起提供的Qt Creator CDB 扩展库:

  1. 在远程机器上安装Windows 调试工具。安装文件夹中包含 CDB 命令行可执行文件(cdb.exe )。
  2. Qt Creator CDB 扩展库及其依赖项从 Qt 安装目录复制到远程机器上的新文件夹中(根据所使用的 Windows 调试工具版本,选择 32 位或 64 位版本):
    • \lib\qtcreatorcdbext32 (32 位)
    • \lib\qtcreatorcdbext64 (64 位)
  3. 将 _NT_DEBUGGER_EXTENSION_PATH 环境变量设置为指向该文件夹。
  4. 若要使用 TCP/IP 作为通信协议,请按以下方式启动远程 CDB:
    cdb.exe -server tcp:port=1234 <executable>
  5. 在运行Qt Creator 的本地计算机上,选择Debug >Start Debugging >Attach to Remote CDB Session
  6. 在“Connection ”字段中输入连接参数。例如,对于 TCP/IP:
    Server:Port

    如果您选择了其他协议,请指定以下替代格式之一:

    tcp:server=Server,port=Port[,password=Password][,ipversion=6]
    tcp:clicon=Server,port=Port[,password=Password][,ipversion=6]
    npipe:server=Server,pipe=PipeName[,password=Password]
    com:port=COMPort,baud=BaudRate,channel=COMChannel[,password=Password]
    spipe:proto=Protocol,{certuser=Cert|machuser=Cert},server=Server,pipe=PipeName[,password=Password]
    ssl:proto=Protocol,{certuser=Cert|machuser=Cert},server=Server,port=Socket[,password=Password]
    ssl:proto=Protocol,{certuser=Cert|machuser=Cert},clicon=Server,port=Socket[,password=Password]
  7. 选择“OK ”以开始调试。

要指定用于管理 CDB 进程的设置,请转至“Preferences ”>“Debugger ”>“CDB ”。

另请参阅 《操作指南:调试》《CDB》、《调试》和《调试器》。

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.