# 远程调试

> For the complete documentation index, see [llms.txt](https://www.jetbrains.com/zh-cn/help/clion/llms.txt).

通过   gdbserver/lldb-server  进行远程调试在目标设备上构建代价高或不可用的情况下特别有用：在将二进制文件放置到目标设备并在 [gdbserver](https://sourceware.org/gdb/onlinedocs/gdb/Server.html)或 [lldb-server](https://lldb.llvm.org/man/lldb-server.html)下启动后，您可以从 CLion 连接到它，并获得完整的 IDE 调试体验，就像您的程序在本地运行一样。

CLion 提供了两种用于远程 gdbserver/lldb-server 调试的配置， [Remote GDB Server](remote-gdb-server.html)（仅适用于 GDB）和 [Remote Debug](remote-debug.html)（适用于 GDB 和 LLDB）。

* 如果您使用 CMake 项目，并希望 CLion 自动构建并上传二进制文件到远程机器，请使用 远程 GDB 服务器 。 此配置还会为您在 gdbserver 下启动程序，因此您无需手动执行此操作。

* 如果您已经有可执行文件和符号文件，请使用 远程调试 。 此配置独立于特定的构建系统或项目格式。 请注意，您需要手动同步文件并在 gdbserver/lldb-server 下启动您的程序。

## 系统和 IDE 配置

|  |    远程调试    |    远程 GDB 服务器    |
| --- | --- | --- |
|    本地操作系统    |     适用于 GDB 的 macOS / Linux / Windows；       适用于 LLDB 的 macOS / Linux     |  macOS / Linux / Windows  |
|    远程操作系统    |     支持 gdbserver 的任何操作系统（适用于 GDB）；       支持 lldb-server 的 macOS / Linux 或其他操作系统（适用于 LLDB）     |  支持 gdbserver 和 SSH 的任何操作系统  |
|    连接协议    |  TCP / UDP 或串行线路  |     TCP / UDP 或串行线路；       用于上传的 SSH     |
|    必需工具    |  [gdbserver](https://sourceware.org/gdb/onlinedocs/gdb/Server.html) 或 [lldb-server](https://lldb.llvm.org/man/lldb-server.html) 在目标上  |  [gdbserver](https://sourceware.org/gdb/onlinedocs/gdb/Server.html) 在目标上  |
|    源代码位置    |     本地；       符号文件也放置在本地     |  本地  |
|    同步    |  手册  |  适用于二进制文件的自动化  |
|    构建    |  未指定  |  本地（需要交叉编译）  |
|    运行/调试    |     程序在 gdbserver/lldb-server 下远程运行；       CLion 的 GDB/LLDB 连接到正在运行的进程并在本地调试     |     程序在 gdbserver 下远程运行；       CLion 的 GDB 连接到正在运行的进程并在本地调试     |

## 项目级设置

|  |    远程调试    |    远程 GDB 服务器    |
| --- | --- | --- |
|    项目格式    |  任意  |  CMake  |
|    工具链    |  未指定  |     macOS/Linux 上默认；       Windows 上的 MinGW、Cygwin、WSL；       也可用远程和 Docker 工具链     |
|    路径映射    |     未自动创建，       需要在 [运行/调试配置](remote-debug.html#remote-config) 中设置     |     未自动创建，       需要在 [运行/调试配置](remote-gdb-server.html#remote-config) 中设置     |

## See also

### 操作指南

[Remote development overview](remote-development.html)

