Why are my breakpoints not hit in CLion?

27,180

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 as Configuration

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

My case

Share:
27,180

Related videos on Youtube

mstrap
Author by

mstrap

Updated on April 29, 2022

Comments

  • mstrap
    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
      Searene over 4 years
      Thanks, your question solved my problem, adding SET(CMAKE_BUILD_TYPE Debug) worked for me.
    • Bernardo Rodrigues
      Bernardo Rodrigues about 3 years
      same here! thanks!
    • jimboweb
      jimboweb over 2 years
      I 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
      jimboweb over 2 years
      My 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 years
    If you need to append your own debug flags, this is the fix:: set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -D_DEBUG")
  • frogEye
    frogEye over 5 years
    In configuration I dnt see Debug as an option. Can you please suggest how to add debug as an option in configuration.
  • Michael Mairegger
    Michael Mairegger over 5 years
    @Vishal You can find the steps in Creating and Editing Run/Debug Configurations
  • Arnaud Mégret
    Arnaud Mégret about 4 years
    CLion 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 years
    In 2019.2 the path is slightly different: File -> Settings -> Build, Excution, Deployment -> CMake
  • V-Mor
    V-Mor about 1 year
    Oh, man! Thank you so much! It resolved my problem. Your answer is one of the most underestimated!
  • Gulzar
    Gulzar about 1 year
    @mstrap If this is the problem, what is the fix? just delete it?
  • mfbutner 8 months
    Same issue for me. Anyone know why a comma breaks things?