Monday, October 19, 2009

Breakpoint Woes

I am having some serious breakpoint woes with Qt Creator 1.2.92 at the moment. Breakpoints work fine the first time I set them, but once the application has been terminated, attempting to add/remove breakpoints will fail and they are never triggered. This is driving me nuts and only a restart of Qt Creator seems to fix it.

Reproducing this problem is easy.
  1. Fire up Qt Creator and create a new Qt4 Console Application project.
  2. In main() set a breakpoint on the first line of code.
  3. Hit F5 to debug. The breakpoint is triggered.
  4. Quit the application, then set a new breakpoint, or remove the existing one and set it again.
  5. Hit F5 to debug. The breakpoint won't be triggered.
It looks like the second time gdb is started you can only set breakpoints once the application is being debugged. This is all well and good for a GUI app where you may have the opportunity to toggle the breakpoint as your app is running, but for applications such as unit test projects, you don't have time to do this before the application quits!

I find it hard to believe that something so fundamental is broken so if anyone has any hints, I'll be grateful. FWIW I am using the version of gdb that ships with Qt Creator 1.2.92. I have tried pointing this to the 2009.03 version instead, but it makes no difference at all.

Now, what I think is happening is this... when Qt Creator starts a debug session it should apply any breakpoints you've set by registering them with gdb. This explains why, until you debug your app, the breakpoint symbol in your code has a little wait cursor next to it:


When you debug your app the first time this icon changes as Qt Creator successfully applies the breakpoint:


Any new breakpoints you add stay displayed with the wait cursor so it looks like Qt Creator isn't applying them.

5 comments:

  1. I'm also having trouble Qt neglecting all breakpoints when debugging. It used to work, but no longer. I new with Qt and C++, and find this bug/problem/whatever very, very troublesome.

    ReplyDelete
  2. What version of Creator are you using because this issue was fixed in the current build IIRC.

    ReplyDelete
  3. I just downloaded the latest 4.8 Qt Creator on March 15, 2012.
    Same problem. It worked at first, then it started ignoring all breakpoints. I too get the timer symbol. No idea why.

    If i click on projects button in lower left corner, i am definitely running Debug version.

    This is really annoying. It's like having the best car on the block, the only problem is the ignition doesn't work.

    any help?

    kesten

    ReplyDelete
    Replies
    1. Did you find any solution to that? I am having the same issue...

      Delete
  4. I had the same problem; for me, an old gdb version screwed it up. Make sure your gdb is up to date AND THAT QT IS USING THE NEWEST ONE ;-)

    Regards,

    ReplyDelete