Debugger: any way to breakpoint after several loop iterations?



  • I hope this makes sense. I have a program that has nested loops, which would make stepping through very cumbersome. I'd like to be able to put a breakpoint somewhere in the middle of the outer loop. For example, if it runs 64 times, I'd like it to break after, say, 32 iterations, and then step through it.

    Is there some kind of conditional break I can put on the loop index, like "break with I > 32"? Any other techniques would be appreciated, too.

    Thanks.


  • Moderators

    Yes, most debuggers support this. Check the documentation of your preferred debugger.



  • Hi, Tobias –

    I just use gdb, and I use it entirely through the Creator interface. Assuming I find the gdb command for this, how do I access it through Creator?


  • Moderators

    Just enter it into the top left area of the debugger mode (not 100% sure that is the right area, I have reordered stuff in my debug mode:-). You can interact with gdb normally there. Ctrl-Return will pass the command on to the debugger.

    Of course you could also use the "condition" field in the breakpoint configuration window (Right click on the breakpoint and choose "edit breakpoint" or something, sorry, I have no creator handy right now to look up the exact terms).



  • I like the second suggestion much better. There's also an "ignore count" that I can use to do the same thing, more or less.

    What is the format for a valid condition? I tried "i < 10" (i is the index of the loop where the break is) but it doesn't stop.

    Thanks.


  • Moderators

    No idea, I never used it:-) My guess is that it is passed directly to GDB, so it should be in whichever format GDB expects the condition.

    If you have questions on the debugger you better ask on the Qt Creator mailing list: The guys doing the debugger do hang out there but only very rarely read this forum.



  • Hey, Tobias -

    I've obviated the original problem for now, but I'd like to know more about this:

    Just enter it into the top left area of the debugger mode (not 100% sure that is the right area, I have reordered stuff in my debug mode:-). You can interact with gdb normally there. Ctrl-Return will pass the command on to the debugger.

    My debugger window doesn't show any place for entering something to pass to the debugger. Can you tell me where this "lives?"

    Thanks.


  • Moderators

    The "debugger log" has the input area: It is the left one of the two text areas the log contains. It has a line edit labeled "Command".

    Press Ctrl-Enter to actually send the input on to the debugger.



  • Hmm...OK, all I have is two bare text areas. No labels, nothing in them except text that appears to be going to/coming from the debugger. The left area seems to contain commands, preceded by numbers, like this:

    bq. 1show version
    2set print static-members off
    3set breakpoint pending on
    4set print elements 10000
    5set overload-resolution off
    6handle SIGSEGV nopass stop print
    7set unwindonsignal on
    8set width 0
    9set height 0
    10-interpreter-exec console "maintenance set internal-warning quit no"

    But, typing in there and hitting ctrl-enter doesn't seem to do anything.

    Come to think of it, I'm not sure where the commands in the left area are coming from.



  • If anyone can help me figure out where the debugger input area is, I'd appreciate it. Here's a picture of my Qt window in debugging mode:

    !http://www.scopedin.com/images/qt.jpg(Qt window)!


  • Moderators

    Hmmm... my creator has a input line beneath the top left of the aceas (the one with the 36-gdb-exit) to input commands in. IIRC that was added to make it more discoverable that you can actually send commands to the debugger which used to work before IIRC.

    Try typing into the top-left area and hitting Ctrl-Return.



  • I'm pretty sure it won't accept anything, but I'll try. I'm a bit embarrassed to say, however, that I don't know how to use GDB directly, so I don't know what to type in there. What do you suggest?


  • Moderators



  • OK, I downloaded the manual (585 pages!) and tried a simple break command. Nothing. It echoed my input (including the line-break) in the left window, but nothing in the right window and the break didn't take.



  • you could just add an @if(i > 32) { qDebug() << "32";}@ in the loop and make a regular breakpoint in the if statement



  • Mmm.... my approach to this would be using DDD (data display debugger? or sth like it) as an interface to GDB, then setting some breakpoints...

    --


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.