Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a gdb command to finish a loop construct?

In gdb, I have the finish command to easily finish execution of a function frame, often when walking through code in the debugger, after looking at a few iterations of a loop, I'd like to finish the loop and continue walking after it. Presently, I do this by setting a break point on the first line after the loop and continue, however, it would be really handy if there was a simple gdb command to have the same effect of this but not require a break point to be set and later cleared.

Is there anyway in gdb to finish execution of the current loop being executed?

like image 734
WilliamKF Avatar asked Feb 01 '13 16:02

WilliamKF


People also ask

How do I complete a loop in GDB?

Is there a gdb command to finish a loop construct? Execute until on the last line of the loop, or until NNN where NNN is the last line of the loop. (gdb) help until Execute until the program reaches a source line greater than the current or a specified location (same args as break command) within the current frame.

How do I end a process in GDB?

To stop your program while it is running, type "(ctrl) + c" (hold down the ctrl key and press c). gdb will stop your program at whatever line it has just executed. From here you can examine variables and move through your program.

How do you stop an infinite loop in GDB?

Like you can cancel a program on the command line, GDB lets you use ctrl-c to stop a program wherever it currently is. Hit ctrl-c now to break the infinite loop.

What does finish do in GDB?

Description. This command continues execution of the current function until it returns to its caller.


1 Answers

Is there a gdb command to finish a loop construct?

Execute until on the last line of the loop, or until NNN where NNN is the last line of the loop.

(gdb) help until Execute until the program reaches a source line greater than the current or a specified location (same args as break command) within the current frame. 

not require a break point to be set and later cleared.

Temporary breakpoints automatically clear themselves:

(gdb) help tbreak Set a temporary breakpoint. Like "break" except the breakpoint is only temporary, so it will be deleted when hit.  Equivalent to "break" followed by using "enable delete" on the breakpoint number. 
like image 197
Employed Russian Avatar answered Sep 21 '22 12:09

Employed Russian