python -m pdb pdb_break.py
> .../pdb_break.py(7)<module>()
-> def calc(i, n):
(Pdb) break 9, j>0
Breakpoint 1 at .../pdb_break.py:9
(Pdb) break
Num Type Disp Enb Where
1 breakpoint keep yes at .../pdb_break.py:9
stop only if j>0
(Pdb) continue
i = 0
j = 0
i = 1
> .../pdb_break.py(9)calc()
-> print 'j =', j
(Pdb)
**SECOND:**条件也可以使用condition命令应用于现有断点。参数为断点ID和表达式。
$ python -m pdb pdb_break.py
> .../pdb_break.py(7)<module>()
-> def calc(i, n):
(Pdb) break 9
Breakpoint 1 at .../pdb_break.py:9
(Pdb) break
Num Type Disp Enb Where
1 breakpoint keep yes at .../pdb_break.py:9
(Pdb) condition 1 j>0
(Pdb) break
Num Type Disp Enb Where
1 breakpoint keep yes at .../pdb_break.py:9
stop only if j>0
(Pdb)
import pdb; pdb.set_trace()
for i in range(100):
print i
终端调试-
$ python 1.py
> /code/python/1.py(3)<module>()
-> for i in range(100):
(Pdb) l
1
2 import pdb; pdb.set_trace()
3 -> for i in range(100):
4 print i
[EOF]
(Pdb) break 4, i==3
Breakpoint 1 at /code/python/1.py:4
(Pdb) break
Num Type Disp Enb Where
1 breakpoint keep yes at /code/python/1.py:4
stop only if i==3
(Pdb) c
0
1
2
> /Users/srikar/code/python/1.py(4)<module>()
-> print i
(Pdb) p i
3
2条答案
按热度按时间k4emjkb11#
我找到了答案,其实很简单,有一个命令叫做
ignore
,假设你想在第9行的断点处,点击1000次后断点:输出:
Breakpoint 1 at ...
输出:
Will ignore next 1000 crossings of breakpoint 1.
iq0todco2#
条件断点可以通过两种方式设置-
**FIRST:**指定使用
break
设置断点时的条件**SECOND:**条件也可以使用
condition
命令应用于现有断点。参数为断点ID和表达式。source
**更新:**我编写了一个更简单的代码
终端调试-