ipdb调试器,跳出循环

ipdb debugger, step out of cycle

在 ipdb 上调试时是否有命令可以跳出循环(例如,for 或 while)而不必使用其中的断点?

我使用 until 命令跳出列表理解,但不知道如何对整个循环块执行类似的操作(如果可能的话)。

如果您愿意使用其他调试器,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

请注意,与 ipdb 一样,源文本也有语法高亮显示。

我相信这是 until 命令的意图。它就像一个 next 除了当跳转到循环的前一个行号时,它将继续直到退出循环。

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

一般来说,到"step out"的当前函数,使用return

r(eturn)
Continue execution until the current function returns.

您可以使用j <line number> (jump)转到另一行。 例如,j 28 转到第 28 行。

这听起来很明显:跳跃让你跳跃。 这意味着您不会执行您跳转的行:您应该使用它来跳过您不想 运行 的代码。

你可能需要tbreak(临时断点,当它第一次被击中时自动删除。参数与break相同)就像我找到这个页面时所做的那样。