- c - 在位数组中找到第一个零
- linux - Unix 显示有关匹配两种模式之一的文件的信息
- 正则表达式替换多个文件
- linux - 隐藏来自 xtrace 的命令
我用的是Python 2.6.6,用pdb调试我的Python程序,但是我不清楚pdb中的“next”和“until”有什么区别,貌似它们都会一直执行到当前函数的下一行。
最佳答案
pdb 帮助文档是这样描述的:
(Pdb) help next
n(ext)
Continue execution until the next line in the current function
is reached or it returns.
(Pdb) help until
unt(il)
Continue execution until the line with a number greater than the current
one is reached or until the current frame returns
更有帮助,Doug Hellman gives an example in his Python Module Tutorial ofthe Week这说明了差异:
The until command is like next, except it explicitly continues until execution reaches a line in the same function with a line number higher than the current value. That means, for example, that until can be used to step past the end of a loop.
pdb_next.py
import pdb
def calc(i, n):
j = i * n
return j
def f(n):
for i in range(n):
j = calc(i, n)
print i, j
return
if __name__ == '__main__':
pdb.set_trace()
f(5)
$ python pdb_next.py
> .../pdb_next.py(21)<module>()
-> f(5)
(Pdb) step
--Call--
> .../pdb_next.py(13)f()
-> def f(n):
(Pdb) step
> .../pdb_next.py(14)f()
-> for i in range(n):
(Pdb) step
> .../pdb_next.py(15)f()
-> j = calc(i, n)
(Pdb) next
> .../pdb_next.py(16)f()
-> print i, j
(Pdb) until
0 0
1 5
2 10
3 15
4 20
> .../pdb_next.py(17)f()
-> return
(Pdb)
Before until was run, the current line was 16, the last line of the loop. After until ran, execution was on line 17, and the loop had been exhausted.
until
的用途与 eponymous gdb command 相同:
until
Continue running until a source line past the current line, in the current stack frame, is reached. This command is used to avoid single stepping through a loop more than once. It is like the next command, except that when until encounters a jump, it automatically continues execution until the program counter is greater than the address of the jump. This means that when you reach the end of a loop after single stepping though it, until makes your program continue execution until it exits the loop. In contrast, a next command at the end of a loop simply steps back to the beginning of the loop, which forces you to step through the next iteration.
关于python - pdb中 "next"和 "until"有什么区别,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27751198/
我正在启动一个 web api 项目,当我尝试在逻辑层(这是一个单独的 csproj)中设置断点时我注意到了这个问题,它显示了未经验证的断点。 深入研究后,我发现调试控制台显示“无法找到或打开 PDB
我已经下载了 FreeImage 源代码并自己为 X64 MT DLL 进行了静态构建。 一切正常,除了当我在 freeimage.lib 文件中使用链接时,我收到很多烦人的链接器警告,我不太了解原因
Ubuntu 16.04 Python 3.5.2 如果我运行 python,在 virtualenv 中,我会得到 Python 3.5.2。 问题是: (photoarchive) admin@s
在 pdb 模式下,我经常想单步执行一个函数。这是一个说明我可能会做什么的情况。给定代码: def f(x): print('doing important stuff..') res
我有父进程调用它的子进程。我把 import pdb; pdb.set_trace() 进入子进程代码。 当我使用 python -m pdb parent.py 启动父级时,它被卡住了。调试器不响应
这个问题在这里已经有了答案: Cannot find or open the PDB file in Visual Studio C++ 2010 (7 个答案) 关闭 8 年前。 我正在使用最近升
我对 python 和 pdb 比较陌生,但我对 gdb 有很多经验。 我的问题是,如果我在某个时候在我的代码中设置了一些断点,我将想要更改某些内容并重新运行我的调试 session ,同时保留这些断
我对编译器和链接器 PDB 文件分别有什么区别感到困惑(即在 Visual Studio 中,Project Properties > C/C++ > Output Files >程序数据库文件名 v
我有一个 PDB 文件列表。我想使用 BioPython 中的 Bio.PDB 模块提取所有文件的配体(因此,杂原子)并将每个单独保存到 PDB 文件中。 我尝试了一些解决方案,例如:Remove h
尝试使用 pdb 调试我的基于 python 的 roguelike。我想弄清楚的是,函数handle_keys()是否像我所问的那样返回0。我有另一个函数没有按预期运行,所以我试图找出问题发生的地方
我有私有(private) pdb 文件,我必须将其转换为公共(public)文件。有工具吗? 最佳答案 使用PDBCopy . pdbcopy 是 Windows 调试工具的一部分,可通过 Wind
在静态编译的链接阶段在 Windows 上构建时可能会出现 LNK4099 警告。 例如使用 nmake 和 VC10 进行构建时,我收到一连串 LNK4099 警告,例如: libcurl_a_de
我的 Visual Studio 2013 ASP.NET webform 应用程序有 3 个 DLL 程序集。调试时,DLL 和 PDB 仅在三个 DLL 中的两个(项目/VB 模块和一个 C# 模
我有一个 Python 程序,里面有一个函数 foo()。 我使用 PDB 运行程序,并在程序中某处的任意断点处停止。 现在,我可以很容易地从 PDB 中调用 foo(),我只需键入: !foo()
我正在尝试使用 this tutorial 学习 pdb引用自 another stackoverflow question ,我正处于“入门”部分的第 3 步。 In [12]: %paste #
我有 DLL,并且有用于创建 DLL 的确切源代码。当我们从客户那里获得转储文件时,我希望我们的本地符号服务器能够工作。 (在我们产品的下一个补丁/版本之前无法在客户站点更新 DLL) 最佳答案 这似
这个问题可能真的很愚蠢,但就是这样。以下语句触发特定电子邮件的异常: File "/Users/me/tools/maildir-deduplicate/maildir_deduplicate/m
在从我的旧 XP 移动到新的 vista PC 后,我在 VS2005 中的一个旧项目中收到以下几个警告: UnitTest++.vsnet2005.lib(TestRunner.obj) : 警告
我正在尝试使用 Visual Studio 编译 Qt 4.8.6 项目(我使用的是用于 Qt4.8.6 的 visual studio 插件)。我在调试和 Release模式 (-debug-and
我想用ipdb而不是 pdb与 py.test --pdb选项。这可能吗?如果是这样,如何? 显然,我可以使用 import ipdb; ipdb.set_trace()在代码中但需要运行测试,观察它
我是一名优秀的程序员,十分优秀!