PDB - 走出一个功能

Klu*_*dge 17 python python-2.7 pdb ipdb

step在使用pdb/ipdb调试器时,我可以在进入函数后退出一个函数吗?

如果没有这样的选择 - 什么是摆脱步入功能的最快方法?

dav*_*idA 24

正如Arthur评论中所提到的,您可以使用r(eturn)将执行运行到当前函数的末尾然后停止,这几乎从当前函数中退出.然后输入n(ext)一次以完成步骤,返回呼叫者.

文档在这里.

(Pdb) ?r
r(eturn)
        Continue execution until the current function returns.
Run Code Online (Sandbox Code Playgroud)

  • 您可以使用 [`retval`](https://docs.python.org/3/library/pdb.html#pdbcommand-retval) 调试器命令来检查返回值。 (4认同)
  • `r`然后`n`,明白了! (2认同)

Art*_*hur 8

step将继续执行。要在调用堆栈中上下移动,您可以使用up(move up to the call function),然后down以另一种方式返回。

看看文档:https : //docs.python.org/3.6/library/pdb.html#pdbcommand-step

  • 好吧,该文档非常清楚地列出了`r(eturn)`,它完全符合您的要求 (4认同)

Mar*_*oun 5

您可以在函数外添加一个断点并继续直到到达它。例如,如果对您的函数的调用在第 14 行,您可以:

(Pdb) b 15
(Pdb) c
Run Code Online (Sandbox Code Playgroud)