For each target in your project (for CMake, Makefile, and Gradle projects), CLion generates a configuration that can be built and run, and allows you to configure external tools to run before/after the build phase in a separate UI dialog.
Use configuration templates to create configurations for unit testing, remote debug or regular application run.
You can change the executable for any configuration of your choice, or even make a configuration not runnable by changing this value to Not selected.
Build your project by pressing Ctrl+F9 and run the currently selected configuration with Shift+F10.
For debug press Shift+F9.
To help you inspect the state of your code during debugging, CLion equips you with many useful shortcuts like Step over/into (F8/F7), Step out (Shift+F8), or Run to cursor (Alt+F9).
Build-system independent Build Targets allow you to add custom targets and configure any tools to be used for Building/Cleaning the target.
To run and debug Custom Targets from CLion, create a corresponding Run/Debug configuration by using the Custom Build Application template.
To speed up your development cycles in CLion when working with CMake or compilation database projects, use Recompile (Shift+Ctrl+F9). It reruns the compilation for a selected file, without triggering the recompilation of the whole project.
When CMake is used, switch between CMake profiles (and built types) in the run configuration switcher on the toolbar or in the Run (Shift+Alt+F10)/Debug (Shift+Alt+F9) configuration switcher popup.
CLion uses PTY as an I/O unit, which means that you can expect a behavior similar to running your project in a terminal, even on Windows.
Develop remotely from a Windows, Linux, or macOS client machine to a Linux remote host, for CMake-based projects only. The current setup assumes the source code is located on a local machine, which CLion synchronizes to the remote machine.
To start developing remotely, create a remote toolchain in Settings/Preferences | Build, Execution, Deployment | Toolchains. Provide the remote host address and credentials, and then use the toolchain in one or several CMake Profiles. After CMake is reloaded, you’ll be ready to start working remotely with your project in CLion.
CLion integrates with the GDB backend on all platforms and LLDB on macOS and Linux.
CLion allows you to debug processes, run on the same machine but not started from the IDE, by attaching to them using their pid or process name. Benefit from CLion’s built-in debugger UI for local processes with GDB on Linux/Windows and LLDB on macOS/Linux.
Having executable running on one machine under gdbserver, you can connect to it with the GDB from CLion from another machine and inspect the code using all the benefits of CLion’s debugger UI.
Use special GDB Remote Debug or Remote GDB Server configuration template to provide settings for the remote connection.
CLion includes an integrated debugger to help you inspect your code’s execution. You can select among several types of breakpoints in CLion (all the breakpoints can be reviewed in a separate dialog (available via Ctrl+Shift+F8)):
With a Set Execution Point to Cursor action, you can move back and forth
though your program’s execution while debugging, break loops or restart them,
select another branch in an
if-else clause or
statement, and even skip loops completely. It is as simple as dragging-and-dropping
an arrow in the gutter to the line you are interested in.
The description of all available variables, including STL containers content will be placed in Variables tab in Debug tool window. There you can observe and even change any value without interrupting current debug session:
GDB/LLDB tab provides access to GDB/LLDB console, while Frame and Watches views help investigate any problem in more detail. As a bonus, when selecting a symbol to watch you can benefit from autocompletion.
In addition, you can evaluate any expression during a debugging session, simply by pressing Alt+F8.
With this feature you can view current variable values right in the editor (next to the variable declaration). No need to switch to the Variables tab in the Debug tool window!
When sources are not available, step into disassembly code. Read the assembly, which is properly highlighted in the editor, and step through it to investigate the problem.
To get into disassembly code, use Force Step Into (Shift+Alt+F7). The usual Step Into (F7) will simply skip all frames without sources.
Supported for GDB and LLDB.
Memory View dumps the memory behind the pointer in the Debug mode. To invoke it, select a pointer variable in the debugger’s variables view and press Ctrl+Enter.
During stepping, if you have Memory View opened, CLion will highlight the memory changes that take place in the selected memory piece.
Navigate to a particular address in memory from the Memory View. Use the hex value
representing an address, a pointer variable, or call the address (
&) of any
variable you are interested in.
Code completion will assist you with the known symbols.
CLion can run and debug your application with root privileges – you just need to select this option in the corresponding Run/Debug configuration. This works for CMake, Makefile, Gradle Native, Custom Build, and CTest applications.
A Run | Open Core Dump… action available for Linux and macOS allows you to open an existing core dump of a crashed process in CLion and debug it there. Users can inspect the frames and variables view, check the memory and disassembly view, evaluate expressions, and run debugger commands from the debugger console.