Debugging an attached process with gdb - how to exit a loop

I am debugging code that looks like this:

while (true){
   // do something ...
   size_t i = foo();  // <- bp set here
   if (flag_set) break;
}

// More code follows here ...

I want to break the function call foo (), call it several times, and then completely jump out of the while loop (suppose we are guaranteed that the flag will be set so that we can break out of the loop.

How to completely break out of the cycle ?. completion simply proceeds to the next iteration. I want to do this to exit the current “code snippet” (in this case, the while loop)

+5
source share
5 answers

advance, , break. ( ):

10 while (true){
11   // do something ...
12   size_t i = foo();  // <- bp set here
13   if (flag_set) break;
14 }
15 
16 // More code follows here ...
17 someFunction();

, 12 1, 17, - :

1

17

1 ( ), , 17.

+2

. foo() Debug|Run to Line. , .

+1

. disable . cont. enable .

.

0

jump. Per gdb help, :

jump -- Continue program being debugged at specified line or address
0

. . gdb:

, , , . , . , , , , , , .

0

All Articles