Breakpoints are source code markers that let you suspend program execution at a specific point and examine its behavior.
Once set, a breakpoint remains in your project until you remove it explicitly (except for temporary line breakpoints).
If a file with breakpoints was modified externally, for example, updated through a VCS or changed in an external editor, and the line numbers have changed, breakpoints will be moved accordingly. Note that CLion must be running when such changes are made, otherwise they will pass unnoticed.
Line breakpoints can be set on executable lines of code. Thread execution is suspended before the line with such breakpoint, and CLion displays the stack frames on that thread's stack.
When a debug session hasn't started yet, all line breakpoints are marked the same way:
During a debug session, CLion detects the breakpoints statuses and changes the markers accordingly:
Line breakpoint is successfully resolved by the GDB or LLDB debugger using the provided debug symbols. Such breakpoint can be hit during execution:
Line breakpoint is invalid, which means it can’t be resolved by GDB or LLDB and will never be hit. This can happen when the breakpoint is located out of the executable code or some debugging symbols are missing. CLion detects such situations accurately and updates the icon on the fly (for example, the status will change when you load the proper debug symbols).
Set a line breakpoint
Place the caret at an executable line of code where you want to set a breakpoint.
Click the left gutter next to that line or pressCtrl+F8.
To set a temporary line breakpoint, pressCtrl+Shift+Alt+F8. It will be removed from your project right after it has been hit.
Exception breakpoints are triggered when the specified exception is thrown. They apply globally to the exception condition and do not require a particular source code reference.
Set an exception breakpoint
Press Ctrl+Shift+F8 or selectfrom the main menu.
In the Breakpoints dialog, press Alt+Insert or click , and select C/C++ Exception Breakpoint, Python Exception Breakpoint or.
In the Enter Exception Class dialog, specify an exception class from a library or from your project.
Symbolic breakpoints stop a program's execution when a specific function or method are executed.
Create a symbolic breakpoint
Press Ctrl+Shift+F8 or selectfrom the main menu.
In the Breakpoints dialog, press Alt+Insert or click , and select Symbolic Breakpoints.
Specify the Symbol name and select whether you want this breakpoint to be hit in all modules, or in a specific module only.
For non-exception breakpoints: click the breakpoint in the gutter.
For all breakpoints: from the main menu, select Remove Delete.Ctrl+Shift+F8, select the breakpoint, and click
To avoid accidentally removing a breakpoint and losing its parameters, you can choose to remove breakpoints by dragging them to the editor or clicking the middle mouse button. To do this, go to Drag to the editor or click with middle mouse button. Clicking a breakpoint will then enable or disable it.and select
If you don't need to stop at your breakpoints for some time, you can mute them. This allows you to resume normal program operation without leaving the debugger session. After that, you can unmute breakpoints and continue debugging.
Click the Mute Breakpoints button in the toolbar of the Debug tool window.
When you remove a breakpoint, its internal configuration is lost. To temporarily turn an individual breakpoint off without losing its parameters, you can disable it:
For non-exception breakpoints: right-click it and set the Enabled option as required. You can also toggle them with the middle mouse button if removing breakpoints is not assigned to it.
For all breakpoints: click View Breakpoints Ctrl+Shift+F8 and check/uncheck the breakpoint on the list.
To move a breakpoint, drag it to another line.
To copy a breakpoint, hold Ctrl and drag a breakpoint to another line. This creates a breakpoint with the same parameters at the destination.
Depending on the breakpoint type, you can configure additional properties, such as:
actions to be performed when hitting a breakpoint
dependencies on other breakpoints
conditions that define when a breakpoint must be hit
To edit breakpoint properties pressCtrl+Shift+F8, or right-click a breakpoint in the editor gutter.
Clear to temporarily disable a breakpoint without removing it from the project. Disabled breakpoints will be skipped during the debugging process.
Select to pause the program execution when a breakpoint is hit. Suspending an application is useful if you need to obtain logging information or calculate an expression at a certain point without interrupting the program. If you need to create a master breakpoint that will trigger dependent breakpoints when hit, choose not to suspend the program at that breakpoint.
Select to specify a condition for hitting a breakpoint. A condition is any boolean expression that evaluates to
This expression must be valid at the line where the breakpoint is set, and it is evaluated each time the breakpoint is hit. If the evaluation result is
Select if you want to log the following events to console:
Evaluate and log
Select to evaluate an expression when the breakpoint is hit, and show the result in the console output.
Remove once hit
Select to remove the breakpoint from your project right after it has been hit.
Disable until breakpoint is hit
Select the breakpoint that will trigger the current breakpoint. Until that breakpoint is hit, the current breakpoint will be disabled. You can also select if you wish to disable it again or leave it enabled once it has been hit.
- Quick access to most common settings
Right-click a breakpoint in the editor gutter to quickly disable or suspend it, or set a condition.
- Breakpoints intentions
You can get access to the most common breakpoint actions and filters through intention actions (Alt+Enter).
- Group breakpoints
You can organize breakpoints into groups, for example, if you need to mark out breakpoints for a specific problem.
In the Breakpoints dialogCtrl+Shift+F8, select a breakpoint you want to place in a group and choose from the context menu.
- Move breakpoints
To move a line breakpoint, drag it to the target line.
- Copy breakpoints
To copy a breakpoint, press Ctrl and drag it to the target line.
- Disable breakpoints
To temporarily disable a breakpoint without removing it from the project, hold down the Alt key and click the breakpoint icon in gutter.
- Quick search
If you have many breakpoints in your project, you can add short descriptions to them to search for them easily: right-click a breakpoint in the Breakpoints dialog Ctrl+Shift+F8 and select Edit description from the context menu. Now when you start typing a breakpoint's name, it gets the focus.
- Jump to source
To jump from the Breakpoints dialog to the line of code where the selected breakpoint is set, pressF4.