Why are my breakpoints not hit in CLion?
Solution 1
As it has turned out, the executable was compiled with following CMake options (further down in the script):
SET(CMAKE_C_FLAGS_DEBUG "-D_DEBUG")
This was breaking debug functionality for CLion (it was also breaking most of the debug functionality of gdb
)
Solution 2
I had the same issue today. I figured out that the configuration for the project was not set to Debug
. After setting the configuration to Debug
all the breakpoints are hit.
Please ensure that you have following configuration:
- Select the MenuItem
Run/EditConfigurations
- Select the right
Target
- Select
Debug
asConfiguration
Now the breakpoints should be hit.
Solution 3
In case this helps someone else, it turned out that my (somewhat embarrassing) issue was that I was hitting Run
instead of Debug
. So in the Run menu don't use the play icon, instead choose the cute bug icon instead. Choosing Run was causing it to automatically build the non-debug build so breakpoints wouldn't work. Once I started choosing the bug icon, the breakpoints worked like a charm.
Solution 4
In my case my CMake option CMAKE_BUILD_TYPE was already set to DEBUG on CMake Settings. However, it was the command set(CMAKE_BUILD_TYPE Release) in the CMakeLists.txt, which was merged by git pull and overrode the CMake Settings while execution. I could not figure out earlier as CMake Debug console was showing -DCMAKE_BUILD_TYPE=Debug
When I changed it to set(CMAKE_BUILD_TYPE Debug) breakpoints were hit again.
Solution 5
In case this helps someone else:
In my case I had to set the -DCMAKE_BUILD_TYPE
option to Debug
explicitly in Settings -> Build, Execution, Deployment -> CMake
Related videos on Youtube

mstrap
Updated on April 29, 2022Comments
-
mstrap 7 months
I'm trying to debug an executable which has been created with CMake configuration
SET(CMAKE_BUILD_TYPE Debug)
However, CLion does not hit any breakpoints. What could be the problem?
-
Searene over 4 yearsThanks, your question solved my problem, adding
SET(CMAKE_BUILD_TYPE Debug)
worked for me. -
Bernardo Rodrigues about 3 yearssame here! thanks!
-
jimboweb over 2 yearsI have tried every one of these solutions and none of them works. My program just doesn't stop on my breakpoints. It is almost making it pointless to use Clion, which is sad because I like JetBrains software for every other kind of programming I do.
-
jimboweb over 2 yearsMy issue seems to be connected to this problem with lldb on catalina: github.com/microsoft/vscode-cpptools/issues/3829. But this is dealing with the issue on vscode. Don't know how to reproduce the solution with clion.
-
-
Vyrx over 6 yearsIf you need to append your own debug flags, this is the fix:: set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -D_DEBUG")
-
frogEye over 5 yearsIn configuration I dnt see Debug as an option. Can you please suggest how to add debug as an option in configuration.
-
Michael Mairegger over 5 years@Vishal You can find the steps in Creating and Editing Run/Debug Configurations
-
Arnaud Mégret about 4 yearsCLion documentation is very obscure. I am facing the same problem and am preparing for a long trip to understand the philosophy of configurations, relation with CMake and debuger.
-
HughB over 3 yearsIn 2019.2 the path is slightly different: File -> Settings -> Build, Excution, Deployment -> CMake
-
V-Mor about 1 yearOh, man! Thank you so much! It resolved my problem. Your answer is one of the most underestimated!
-
Gulzar about 1 year@mstrap If this is the problem, what is the fix? just delete it?
-
mfbutner 8 monthsSame issue for me. Anyone know why a comma breaks things?