Embedded GDB Server
To debug on-chip with GDB server, use the dedicated Embedded GDB Server run/debug configuration which covers the following use cases:
ST-Link GDB servers (you can find the open-source version of the tools on GitHub).
Segger J-Link GDB server.
Qemu as a GDB server.
OpenOCD as a standalone GDB server, as an alternative to OpenOCD Download & Run configuration.
Any other boards or specific GDB stubs that comply with the GDB server protocol.
This configuration supports CMake and custom build targets.
Required tools
Toolchain
The Embedded GDB Server configuration requires the cross-compiler toolchain to be configured in advance.
For ARM Cortex-M and Cortex-R MCUs, install GNU ARM toolchain. After the installation, make sure the toolchain is presented in the system PATH: run
arm-none-eabi-gcc
from the command line, and your system should recognize this command.For all other platforms, install the platform-specific toolchain and set up the tools in CMakeLists.txt).
or in your CMake script (take a look at the templateAlso, you need to provide the linker file: obtain it from your chip vendor or create it manually, and specify through CMake settings.
If you are working with an STM32CubeMX project, installing the GNU ARM toolchain is a part of the project set up, and CubeMX generates the linker file automatically.
GDB client
GDB client is the debugger that runs on CLion's side and connects to the remote GDB server. You can use either the bundled GDB or a custom debugger as a GDB client.
By default, CLion employs the debugger selected in the target's toolchain (either a CMake profile or custom target settings).
You can change the client debugger in the Debugger field of the toolchain chosen in or .
GDB server
The chosen GDB server should be installed on your machine. There is no need to launch it manually - the configuration will run the GDB server automatically when you start a debug session.
Create an Embedded GDB Server configuration
Go to
, clickand select Embedded GDB Server.
Configure the following settings:
Target and Executable
Select the target to be built (either a CMake or custom target) and the executable to be uploaded remotely.
Click the
button to configure custom targets in the dialog.
'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
Specify the binary to be used as GDB server.
GDB Server args
Provide the GDB server-specific arguments (for example, port number or board config file).
Advanced options: reset command
The command to be sent when you press
during a debug session.
Advanced options: startup delay
The amount of time CLion will wait after starting the GDB server before attempting to connect.
Debug an Embedded GDB Server configuration
When you Debug this configuration, CLion performs a sequence of steps:
Start GDB server with the specified environment.
Wait until the configured startup delay time passes.
Start GDB client and connect to the GDB server.
Upload the binary as specified by the Download option in the configuration settings.
Start the debug session.
At this point, you can use all the CLion debugging features for your firmware running on-chip:
Notice the
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.