10

During many, sometimes inundating, debugging sessions using DDD, I stumble upon loops. And I keep pressing next to get past it, and if there are many iterations, I just set a break point right after it, and press "continue." Is there any other way to go past loops?

sth
  • 222,467
  • 53
  • 283
  • 367
vehomzzz
  • 42,832
  • 72
  • 186
  • 216
  • Thanks for s/passed/past/g ... English is not my first language, although I am unarguably getting better at it. – vehomzzz Mar 12 '10 at 19:37

2 Answers2

15

You want the "until" command - see the gdb manual at http://www.gnu.org/software/gdb/documentation:

Continue running until a source line past the current line, in the current stack frame, is reached. This command is used to avoid single stepping through a loop more than once. It is like the next command, except that when until encounters a jump, it automatically continues execution until the program counter is greater than the address of the jump.

This means that when you reach the end of a loop after single stepping though it, until makes your program continue execution until it exits the loop. In contrast, a next command at the end of a loop simply steps back to the beginning of the loop, which forces you to step through the next iteration.

3

I typically use the "continue until here" which sets a temporary breakpoint at that location and immediately continues execution. It is accessed via mouse button 3 which opens a popup menu.

Greg
  • 461
  • 3
  • 4