ipdb debugger, step out of cycle
Asked Answered
B

4

31

Is there a command to step out of cycles (say, for or while) while debugging on ipdb without having to use breakpoints out of them?

I use the until command to step out of list comprehensions, but don't know how could I do a similar thing, if possible, of entire loop blocks.

Baier answered 3/7, 2015 at 0:40 Comment(0)
D
15

This could sound obvious: jump makes you jump. This means that you don't execute the lines you jump: you should use this to skip code that you don’t want to run.

You probably need tbreak (Temporary breakpoint, which is removed automatically when it is first hit. The arguments are the same as break) as I did when I found this page.

Distributary answered 30/11, 2016 at 16:13 Comment(0)
A
30

I believe this is the intent of the until command. It's like a next except that when a jump occurs to a previous line number for the loop, it will continue until exiting the loop.

unt(il)
Continue execution until the line with a number greater than the current
one is reached or until the current frame returns

In general, to "step out" of the current function, use return.

r(eturn)
Continue execution until the current function returns.
Alwitt answered 1/8, 2015 at 15:43 Comment(3)
nope, until steps out of list comprehensions for example. It continues execution UNTIL reching a different line number as the current one, just that. If inside some code block (for, while, anything else), there's no way but with breakpoints, as far as I have researchedBaier
@Javier Navoa What you described for until is the behavior of next. I believe he is right: until is just like next except that it always goes down. In that way until can effectively be used to go out of loops, but it can take several times (the number of lines remaining in the loop).Jacelynjacenta
The trap is that the debugger understands list comprehensions as several lines, but it is the same for next and until.Jacelynjacenta
E
24

You can use j <line number> (jump) to go to another line. for example, j 28 to go to line 28.

Echidna answered 19/8, 2015 at 13:54 Comment(1)
as pointed out by jimifiti, jump skips the jumped lines, so it is not similar to untilJacelynjacenta
D
15

This could sound obvious: jump makes you jump. This means that you don't execute the lines you jump: you should use this to skip code that you don’t want to run.

You probably need tbreak (Temporary breakpoint, which is removed automatically when it is first hit. The arguments are the same as break) as I did when I found this page.

Distributary answered 30/11, 2016 at 16:13 Comment(0)
H
1

If you are willing to use another debugger, trepan, has more ways you can step. It is more gdb-like. So you can give a count of how many times you want to step. Or you can give a line number in a continue debugger command which in essence sets a temporary breakpoint at the line and then issues "continue". Other things that change stepping are "set different". See also the even suffixes you can put on step.

Note that like ipdb, there is syntax highlighting of the source text.

Homebrew answered 3/7, 2015 at 2:3 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.