# Embedded GDB Server

> **TL;DR**
> OS: Windows (MinGW or MinGW-w64) / Linux / macOS
>
>
>
> Required tools: a debug probe with software, cross-compiler toolchain
>
>
>
> Build targets: CMake / Makefile / custom build target

To debug on-chip with a GDB server, you need to create a special run/debug configuration. In CLion, you can quickly create configurations using the New Embedded Configuration wizard for the following GDB servers:

* [Segger J-Link](https://www.segger.com/downloads/jlink/#J-LinkSoftwareAndDocumentationPack) GDB server

* [Qemu](https://en.wikibooks.org/wiki/QEMU/Debugging_with_QEMU) as a GDB server

* [PyOCD](https://pyocd.io)

* [st-util](https://github.com/stlink-org/stlink) (open-source GDB server for ST-LINK debug probes)

* ST-LINK_gdbserver (a part of [STM32CubeIDE](https://www.st.com/en/development-tools/stm32cubeide.html))

* [PEmicro (OpenSDA)](https://www.pemicro.com/opensda/)

You can also create a run/debug configuration for any other debug probe software that complies with the GDB server protocol. To do this, add a new Embedded GDB Server configuration from the Run/Debug Configurations dialog. For more information, refer to [Adjust the Embedded GDB Server configuration](#gdbserver-config).

> **Note:**
> You can set up an embedded GDB server using an alternative approach to the one described in this article. The [Debug Servers](debug-servers.html) configuration option offers a more convenient way to configure various gdbservers and combine them with build targets.

Procedure: Before you start

1. Configure a cross-compiler [toolchain](embedded-overview.html#toolchains).

> **Note:**
> On Windows, switch to the [System](quick-tutorial-on-configuring-clion-on-windows.html#system) toolchain (recommended). Alternatively, you can use the [MinGW / MinGW-w64](quick-tutorial-on-configuring-clion-on-windows.html#MinGW) environment.

2. Make sure the selected GDB server is installed on your machine. There is no need to launch it manually: the configuration will [run the GDB server](#run-debug) automatically when you start a debug session.

Procedure: Create an Embedded GDB Server configuration

1. Select the `Run | New Embedded Configuration` action in the main menu.

2. In the wizard that opens, set up the following:

![New Embedded GDP Server](https://resources.jetbrains.com/help/img/idea/2026.2/cl_embedded_config_wizard.png)

* GDB Server type: select the type of the GDB server. CLion will automatically predefine necessary arguments for this server.

* Location: specify the full path to the binary that will be used as a GDB server. > **Tip:** > For STM32CubeIDE ST-LINK GDB Server, specify the path to the STM32CubeIDE binary. > > > > For PE-Micro, specify the path to a platform-specific binary. See more details in [Set up the PEmicro GDB server](#pemicro).

* Debugger: select the GDB debugger, which will run on the CLion's side and connect to the remote GDB server. Use either the bundled GDB or your custom GDB binary.

* Target and Executable binary: select the target to be built and the executable binary that will be downloaded to the device.

* Download executable: specify when to download the executable binary to the target device: * Always: every time you start a debug session. * If updated: only upon the changes in the binary. * None: skip downloading.

* TCP/IP port: explicitly specify a port for the GDB server or leave this field empty to use a random one.

3. Click Next. On the next wizard page, you can adjust the settings specific to the selected GDB server type. For example, for the Segger JLink server, you can select a transport interface type, initial speed, and a device:

![GDB server devices](https://resources.jetbrains.com/help/img/idea/2026.2/cl_GDB_wizard_devices.png)

4. Click Create. A new run/debug configuration for an embedded GDB server will be created with the necessary arguments for the specified server. See the next procedure on how to adjust it.

Procedure: Adjust the Embedded GDB Server configuration

1. Go to `Run | Edit Configurations` and select the configuration that you want to edit.

> **Note:**
> If there is no GDB configurations available, you can create a new one by clicking ![](https://resources.jetbrains.com/help/img/idea/2026.2/app.expui.general.add.svg) and selecting Embedded GDB Server in the Run/Debug Configurations dialog or by using the [New Embedded Configuration](#create_GDB_config) wizard

2. From here, you can configure the following settings:

![Embedded GDB server configuration](https://resources.jetbrains.com/help/img/idea/2026.2/cl_GDB_configuration_advanced.png)

* Debugger: select the GDB debugger, which will run on the CLion's side and connect to the remote GDB server. Use either the bundled GDB or your custom GDB binary.

* Target and Executable binary: select the target to be built and the executable binary that will be downloaded to the device.

* Download executable: specify when to download the executable binary to the target device: * Always: every time you start a debug session. * If updated: only upon the changes in the binary. * None: skip downloading.

* 'target remote' args: provide the medium to carry debugging packets (serial line or an IP network using TCP or UDP). For more information about connecting to a remote target, refer to [gdb documentation](https://sourceware.org/gdb/onlinedocs/gdb/Connecting.html#Connecting).

* GDB Server: specify the binary to be used as a GDB server.

* GDB Server args: provide the GDB server-specific arguments (for example, port number or board config file).

* `Advanced GDB Server Options | Reset command`: by default, this command is sent after flashing the MCU and also when you press ![MCU reset](https://resources.jetbrains.com/help/img/idea/2026.2/clion-embedded.icons.expui.resetMcu.svg) during a debug session. It usually starts with [monitor](https://sourceware.org/gdb/current/onlinedocs/gdb/Server.html), and the rest of the line is passed to the GDB server directly. Note that most GDB servers support several reset commands (refer to your vendor-specific documentation). Reset can be performed at different stages: Before or After flashing MCU ROM or writing to RAM, Always (both before and after), or Never. ![Embed gdb server reset options](https://resources.jetbrains.com/help/img/idea/2026.2/cl_embed_sgbserver_reset_options.png)

* `Advanced GDB Server Options | Startup delay`: the amount of time CLion will wait after starting the GDB server before attempting to connect.

Procedure: Debug an Embedded GDB Server configuration

When you Debug![](https://resources.jetbrains.com/help/img/idea/2026.2/app.actions.startDebugger.svg) this configuration, CLion performs a sequence of steps:

1. Start GDB server with the specified environment.

2. Wait until the configured startup delay time passes.

3. Start GDB client and connect to the GDB server.

4. Upload the binary as specified by the Download option in the configuration settings.

5. Start the debug session.

Now your firmware running on-chip can be debugged using the entire set of CLion debug features, including [Memory view](memory-view.html), [multi-threaded RTOS debug](rtos-debug.html), and  the [Peripherals](peripheral-view.html) tab showing peripheral registers and bits.

![Debugging an Embedded GDB Server configuration](https://resources.jetbrains.com/help/img/idea/2026.2/cl_embed_gdbserver_debug.animated.gif)

Notice the ![MCU reset](https://resources.jetbrains.com/help/img/idea/2026.2/clion-embedded-plugin.icons.expui.resetMcu.svg) button on the left-hand bar of the Debugger tool window. When pressed, it sends the chip reset command specified in the Reset command field of the configuration settings.

Procedure: Set up the PEmicro GDB server

1. Download [PEmicro GDB Server for ARM devices - Eclipse Plugin](https://www.pemicro.com/products/product_viewDetails.cfm?product_id=15320151&productTab=3) (registration required).

2. Unzip the downloaded archive to a temporary folder.

3. Unzip the `plugins/com.pemicro.debug.gdbjtag.pne_<version>.jar` file into a desired installation folder.

4. Use the `\win32\pegdbserver_console.exe` , `osx/pegdbserver_console`, or `lin/pegdbserver_console` file from that folder as a GDB Server binary, depending on your operating system.

## See also

### External Links

[Embedded Development in CLion FAQs](https://intellij-support.jetbrains.com/hc/en-us/articles/4405160320274-Embedded-Development-in-CLion) [Using nRF52 with CLion](https://blog.jetbrains.com/clion/2020/01/using-nrf52-with-clion/) [Tutorial: Using nRF52 With nRF Connect SDK, CMake, and CLion](https://blog.jetbrains.com/clion/2021/04/using-nrf52-with-cmake-connect-sdk/)

