Debugger: any way to breakpoint after several loop iterations?
-
wrote on 19 Mar 2011, 02:32 last edited by
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.
-
wrote on 19 Mar 2011, 06:06 last edited by
Yes, most debuggers support this. Check the documentation of your preferred debugger.
-
wrote on 19 Mar 2011, 06:19 last edited by
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?
-
wrote on 19 Mar 2011, 18:14 last edited by
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).
-
wrote on 19 Mar 2011, 22:11 last edited by
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.
-
wrote on 20 Mar 2011, 08:39 last edited by
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.
-
wrote on 22 Mar 2011, 04:37 last edited by
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.
-
wrote on 22 Mar 2011, 08:06 last edited by
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.
-
wrote on 22 Mar 2011, 15:40 last edited by
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.
-
wrote on 25 Mar 2011, 17:43 last edited by
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)!
-
wrote on 25 Mar 2011, 18:28 last edited by
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.
-
wrote on 25 Mar 2011, 18:32 last edited by
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?
-
wrote on 25 Mar 2011, 21:28 last edited by
"google helps":http://www.lmgtfy.com/?q=gdb+manual...
-
wrote on 25 Mar 2011, 22:31 last edited by
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.
-
wrote on 14 Apr 2011, 08:32 last edited by
you could just add an @if(i > 32) { qDebug() << "32";}@ in the loop and make a regular breakpoint in the if statement
-
wrote on 14 Apr 2011, 09:02 last edited by
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...
--