'Why are my breakpoints not hit in CLion?

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?



Solution 1:[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:[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 as Configuration

Now the breakpoints should be hit.

Solution 3:[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:[4]

I also had the same Problem. Since 2016.3 CLion changed the CMake workflow so that only one configuration is allowed at one time clion new workflow

The solution is File -> Settings -> Build, Excution, Deployment -> change the build configuration

Solution 5:[5]

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 6:[6]

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

My case

Solution 7:[7]

I had a comma in my project path. Removing the comma fixed the problem for me.

Solution 8:[8]

In 2019.3, it turns out to be CLion/Preference/Build,Execution,Deployment/CMake/Build type/Debug.

Solution 9:[9]

My problem was with the -ffile-prefix-map flag. Once I removed it, everything worked fine.

See https://youtrack.jetbrains.com/issue/CPP-23159 and https://youtrack.jetbrains.com/issue/CPP-15850

Solution 10:[10]

I had the same issue. I noticed that every time I click the debug option, the "Antimalware Service Executable" process starts. I created an exclusion for MinGW folder in windows Defender and it worked fine...

Solution 11:[11]

Just like minecrawler said in github, if your os is linux, your should set?

file/Settings/Build,Execution,Deployment/Tllochains/Debugger from Bundled GEB or gdb to Bundled LLDB.

I tried and it worded?

Solution 12:[12]

In my case (Linux / Ubuntu) the problem was somehow related to mounted directory. The project was initially opened in CLion from /media/username/ssd/repo/git/projectname. The breakpoints were always disabled with message No executable code is associated with this line.

Then I opened the same project from a symlinked directory ~/git -> /media/username/ssd/repo/git and the breakpoints began to work fine.

Solution 13:[13]

In my case I had to edit the file so that everything was compiled again instead of using cache.

Solution 14:[14]

In my case, the problem is forget to comment out optimize option add_definitions(-O3) in cmakelists. which let compiler go release.

Solution 15:[15]

I had a different issue that caused my breakpoints not to be hit. I develop both embedded apps and native MacOS console apps with CLion. For the embedded work, GDB needs to be set for your selected Preferences/Toolchains.

For debugging console apps LLDB needs to be selected in Preferences/Toolchains. If it is left on GDB, my breakpoints don't work. Set to LLDB here:

enter image description here