Continue an iteration in C++ until a specific iteration number in gdb

c++, gdb

Solution

When you set the breakpoint it'll give you a breakpoint number (for the moment, let's assume it's 1). You'll then make that breakpoint conditional, something like:

condition 1 i==end/2

Problem

I am using gdb-7.0.1 and I think I have detected a bug in a certain section of my code, which has a `for` loop. The `for` loop looks like ``` for (int i=0 ; i< end ; ++i ) { //Code here. } ``` Here `end` is a very large integer. The code does not crash at the first iteration, and seems to crash somewhere at iteration number `end/2`. Since I want to understand the behaviour of the code at iteration number `end/2` , just `stepping` and `nexting` from `i=0` till I reach this iteration point, is unfeasible. Is there a way to tell `gdb` to continue through a for loop till `i` gets the value `end/2` and then wait for the user to manually step through iteration number `end/2`? I am using `gcc-4.5.2` on Ubuntu Linux

Original source

Related problems