Run

Configurations

For each target in your CMake files, 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.

In addition, CLion generates a default all-target configuration, which you can find in the
configurations list, edit, select for build and run. To run this configuration, CLion asks
you to select an executable. Generally 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.

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.

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

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.

Run with Valgrind Memcheck

On Linux and macOS platforms CLion integrates with Valgrind Memcheck to help you detect memory errors.

It lets you run targets with Valgrind Memcheck and
then get the results in a special tab in the Run tool window. Users can run both regular
targets and unit tests targets with Memcheck.

Debug

CLion integrates with the GDB backend on all platforms and LLDB on macOS and Linux.

Attach to local process

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.

Remote GDB debug

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 configuration template to provide settings for the remote connection.

Breakpoints

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

Line breakpoints are the easiest way to debug your code. Simply set a breakpoint with the mouse by clicking in the left-hand gutter of a line.

Symbolic breakpoints help you stop program execution when a specific function starts executing. Find a symbol by its name, taking advantage of code completion, to go to the appropriate function.

Exception breakpoints help catch any thrown exception without any extra hassle.

Watches and evaluations

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.

Inline variable view

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!

Disassembly view

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.