Remote GDB Server
The Remote GDB Server configuration builds your CMake target locally, uploads the binary to the remote machine, launches it under gdbserver, and connects the CLion debugger.
Create a Remote GDB Server configuration
Go to Run | Edit Configurations, click , and select Remote GDB Server from the list of templates.
Specify the following settings:
Target and Executable
Select the target to be built and the executable to be uploaded remotely.
Click and provide the credentials for accessing your remote machine:
CLion will add this connection entity to the list of server access configurations in.
Your executable can be uploaded every time you start a debug session (Always) or upon the changes in the binary (Updated Only). You can also choose to skip uploading (None).
Specify the remote folder where the executable will be placed.
'target remote' args
Provide the medium to carry debugging packets (serial line or an IP network using TCP or UDP). See gdb documentation for more details on connecting to a remote target.
Set the location of gdbserver on the remote machine. The default path is filled up automatically.
GDB Server args
Specify the arguments that will be passed to gdbserver: connection port, executable path, and additional arguments if required.
By default, this field contains the port you provided in 'target remote' args and the path from Upload path followed by the binary name.
Start a remote debug session
On macOS and Linux, make sure to have GDB selected in the toolchain.
After placing breakpoints in your code, select the newly created Remote GDB Server configuration, and press (Shift+F9).
You can find the build log in the Messages tool window:
To monitor the process of uploading, switch to the File transfer window:
The Console tab of the Debug tool window shows the status of the GDB/gdbserver connection:
You can debug the program as usual: examine the variables, step through, evaluate expressions, and use all the other debug features.