1.2.5 Resuming Execution (step, next, finish, return, continue, jump, skip)

``Continuing'' means resuming program execution until the program completes normally. In contrast, ``stepping'' means executing just one statement of the program. When continuing or stepping, the program may stop even sooner, due to a breakpoint or an exception.

s(tep) [count]

Execute the current line, stop at the first possible occasion (either in a function that is called or on the next line in the current function).

Note that if thread debugging is enabled, the next statement may be in a different thread.

n(ext) [count]

Continue execution until the next line in the current function is reached or the function returns. The difference between "next" and "step" is that "step" stops inside a called function, while "next" executes called functions at (nearly) full speed, stopping only at the next line in the current function.

Note that if thread debugging is enabled, the next statement may be in a different thread. There currently is a bug only in thread debugging where next can act like step.

finish

Continue execution until the current function returns.

See also 1.2.5.

return

Make selected stack frame return to its caller. Control remains in the debugger, but when you continue execution will resume at the return statement found inside the subroutine or method. At present we are only able to perform this if we are in a subroutine that has a return statement in it. See also 1.2.5

c(ontinue) [[filename:]lineno|function]

Continue execution; only stop when a breakpoint is encountered. If a line position is given, continue until that line is reached. This is exactly the same thing as setting a temporary breakpoint at that position before running an (unconditional) continue.

jump lineno

Set the next line that will be executed. available only in the bottom-most frame. This lets you jump back and execute code again, or jump forward to skip code that you don't want to run.

Not all jumps are allowed--for instance it is not possible to jump into the middle of a for loop, into a try block or out of a finally clause.

One common use for the jump statement is to get out of a loop. Sometimes the bounds of loops are computed in advance so you can't leave a loop early by say setting the value of the loop variable

Here's an example demonstrating this:

pydb ptest.py
(ptest.py:2): 
(Pydb) list
  1  	#!/bin/python
  2  ->	for i in range(1,10):
  3  	    print i
  4  	print "tired of this"
[EOF]
(Pydb) step
(ptest.py:3): 
(Pydb) i=1000
(Pydb) step
1000
(ptest.py:2): 
(Pydb) jump 4
(ptest.py:4): 
(Pydb) step
tired of this
--Return--
--Return--
The program finished and will be restarted
(ptest.py:2): 
(Pydb)

Note that the assignment of 1,000 to i took effect, although it had no effect on terminating the for loop; jump was needed to get out of the loop early.

skip [count]

Set the next line that will be executed to be the line number which is count line boundaries away from the current line. By default, count is one which will skip the current line about to be executed.

This command works by disassembling instructions from the current line until a new line number boundary is found and does in effect a jump to that line. So beware, we are not statement boundaries.

Since this works underneath the same as jump, the same caveats mentioned apply wiht respect to where you cannot jump to.

See About this document... for information on suggesting changes.