CLion 2022.3 Help

Remote GDB Server

The Remote GDB Server configuration builds your target locally, uploads the binary to the remote machine, launches it under gdbserver, and connects the CLion debugger.

Create a Remote GDB Server configuration

  1. Go to Run | Edit Configurations, click App general add, and select Remote GDB Server from the list of templates.

  2. Specify the following settings:

    Remote GDB Server configuration

    • Target and Executable

      Select the target to be built (CMake, Makefile, or custom target) and the executable to be uploaded remotely.

      Click the App general gear plain button to configure custom targets in the Settings | Build, Execution, Deployment | Custom Build Targets dialog.

    • GDB

      Select the client debugger: bundled multiarch GDB (default), one of the toolchain debuggers, or a custom GDB binary.

    • Credentials

      Select one of the existing SSH configurations from the drop-down list or click App general gear plain to create a new one. Provide the credentials for accessing your remote machine:

      remote credentials

    • Upload executable

      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).

    • Upload path

      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.

    • GDB Server

      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

  1. Make sure to select GDB as your toolchain debugger.

    • On macOS and Linux, go to Settings | Build, Execution, Deployment | Toolchains and select one of the available GDB options in the Debugger field of the current toolchain.

    • Note that on Windows, Remote GDB Server configurations can't be used with the Visual Studio toolchain since the debugger it employs is based on LLDB.

  2. After placing breakpoints in your code, select the newly created Remote GDB Server configuration, and press App actions start debugger (Shift+F9).

    • You can find the build log in the Messages tool window:

      build log
    • To monitor the process of uploading, switch to the File transfer window:

      file transfer
    • The Console tab of the Debug tool window shows the status of the GDB/gdbserver connection:

      remote debug console
  3. You can debug the program as usual: examine the variables, step through, evaluate expressions, and use all the other debug features.

    debugging with remote GDB server

Last modified: 11 January 2023