Local Operating System: macOS / Linux / Windows
Remote Operating System: Any system that supports gdbserver, SSH, and SFTP
Required Tools: gdbserver on the target machine
Binary File Synchronization: Automatic
Client Debugger: Bundled GDB / GDB from Toolchain / Custom GDB
Build Targets: CMake / Makefile / Custom Build Targets
Configuring the Remote GDB server will build your target locally, upload the binary file to the remote machine, start it under gdbserver, and connect to the CLion debugger.
👇 Click to Claim 👇
👉 Collection of C Language Knowledge Materials
To create a remote GDB server configuration, go to Run | Edit Configurations in the main menu, click , and select Remote GDB Server from the template list. Specify the following settings:
-
Target and Executable File
Select the target to build (CMake, Makefile, or Custom Target) and the executable file to be uploaded remotely.
Click
button to configure custom targets in the Settings | Build, Execution, Deployment | Custom Build Targets dialog.
-
GDB
Select the client debugger: Bundled Multi-Architecture GDB (default), a debugger from the toolchain, or a custom GDB binary.
-
Credentials
Select an existing SSH configuration from the dropdown list, or click
to create a new one. Provide credentials to access the remote machine:
You can also manage SSH configurations in Settings | Tools | SSH Configurations.
-
Upload Executable File
You can choose to upload the executable file every time a debug session starts (always), or upload it only when the binary changes (only update). You can also choose to skip uploading (none).
-
Upload Path
Specify the folder on the remote machine where the executable file will be placed.
-
‘target remote’ Parameter
Provide the medium for transferring the debug package (serial line or IP network using TCP or UDP).
-
GDB Server
Set the location of gdbserver on the remote machine. The default path will be filled automatically.
-
GDB Server Parameters
Specify the parameters to be passed to gdbserver: connection port, executable file path, and additional parameters if necessary.
By default, this field contains the port you provided in the ‘target remote’ parameter and the path following the upload path along with the binary name.
For CMake projects, by default, this configuration uses the currently selected CMake configuration file to build the target and retrieves the binary file from the build directory folder.
If your setup requires a cross-compilation toolchain, ensure to create it, configure the appropriate debug configuration, and switch to this configuration before starting the session.
Start Remote Debugging Session
-
Ensure GDB is selected as your toolchain debugger.
Ensure your system firewall allows connections to the remote GDB server.
-
On macOS and Linux, go to Settings | Build, Execution, Deployment | Toolchains and select an available GDB option in the debugger field of the current toolchain.
-
Note that on Windows, the Remote GDB Server configuration cannot be used with the Visual Studio toolchain as it uses a debugger based on LLDB.
After placing breakpoints in the code, select the newly created Remote GDB Server configuration and press (ShiftF9).
-
You can find the build log in the Messages tool window:
-
To monitor the upload process, switch to the file transfer window:
-
The console tab of the debugging tool window shows the status of the GDB/gdbserver connection:
You can debug the program as usual: inspect variables, step through, evaluate expressions, and use all other debugging features.
Popular Recommendations
-
In this day and age, do drivers need to know Linux?
-
The most powerful free open-source music software, supports PC and mobile!
-
Ridiculous operation, investigated by the former company after resignation…