Search code examples
debugginggdbvisual-studio-debugging

GDB: skip through loop iterations


How can i skip over n iterations using GDB? I'm trying to debug a for loop and i want to get to iteration 703, without typing next 703 times.

Attention: I want to remain in the loop, only to skip n iterations.

Thank you!


Solution

  • I found the solution:

    Considering this code:

    for(int i = 0; i < 1000; i++) {
        printf("%d\n",i);
    }
    

    In GDB you have to type: 'break n' ( where n is the line number for the 'for' loop) and then 'c x' - where x is the number of times you want to skip the loop.