You cannot use continue because the new statements in the debugger must be complete and valid without any other context; continue must be specified inside the compilation loop structure. Thus, using !continue (c ! To prevent pdb from interpreting the command) cannot be used even if the debugger is processing the loop construct.
You can use the j[ump] if you have a statement later to jump. If your cycle is empty after the statements you wanted to jump over, you can only "rewind":
$ bin/python test.py > /.../test.py(5)<module>() -> print(str(i)) (Pdb) l 1 import pdb 2 3 for i in range(10): 4 pdb.set_trace() 5 -> print(str(i)) 6 [EOF] (Pdb) j 3 > /.../test.py(3)<module>() -> for i in range(10):
j 3 jumped to line 3 without missing anything; line 3 will be overwritten, including the range() setting. You can go to line 4, but then the for loop does not advance.
You need to add another statement at the end of the loop in order to move on to using Python. This statement can be print() or pass or something else that should not change your state. You can even use continue as the last statement. I used i :
for i in range(10): pdb.set_trace() print(str(i)) i
Demo:
$ bin/python test.py > /.../test.py(5)<module>() -> print(str(i)) (Pdb) l 1 import pdb 2 3 for i in range(10): 4 pdb.set_trace() 5 -> print(str(i)) 6 i # only here to jump to. 7 [EOF] (Pdb) j 6 > /.../test.py(6)<module>() -> i # only here to jump to. (Pdb) c > /.../test.py(4)<module>() -> pdb.set_trace() (Pdb) s > /.../test.py(5)<module>() -> print(str(i)) (Pdb) j 6 > /.../test.py(6)<module>() -> i # only here to jump to. (Pdb) i 1 (Pdb) c > /.../test.py(4)<module>() -> pdb.set_trace() (Pdb) s > /.../test.py(5)<module>() -> print(str(i)) (Pdb) j 6 > /.../test.py(6)<module>() -> i
From the Debugger Command :
j (ump) lineno
Set the next line to be executed. Available only in the bottom frame. This allows you to go back again and execute code or go forward to skip code that you do not want to run.
It should be noted that not all jumps are valid - for example, it is impossible to jump to the middle of a for loop or from a finally clause.
source share