分类: Python/Ruby
2010-10-19 10:09:17
Pdb是一个简单的命令行调试工具。支持事后调试, 检查堆栈, 断点,单步调试和代码检查.调用pdb的函数有:run,runeval,runcall,set_trace(),post_mortem(traceback),pm()。其中set_trace()是最易于使用的。
[!]statement 执行语句;(Pdb) global list_options; list_options = ['-l'],设置变量。
a(rgs): 显示变量列表
alias [name [command]]
b(reak) [loc [, condition]]
cl(ear) [bpnumber [bpnumber ...]]
commands [bpnumber]
condition bpnumber [condition]
c(ont(inue))
disable [bpnumber [bpnumber ...]]
d(own)
enable [bpnumber [bpnumber ...]]
h(elp) [command]
ignore bpnumber [count]
j(ump) lineno
l(ist) [first [, last]]
n(ext)
p expression
pp expression
q(uit)
r(eturn)
run [args]
s(tep)
tbreak [loc [, condition]]
u(p)
unalias name
w(here)
从命令行调用:
% python –m pdb someprogram.py
>
/Users/beazley/Code/someprogram.py(1)
-> import splitter
(Pdb) b splitter.split
Breakpoint 1 at /Users/beazley/Code/splitter.py:1
(Pdb) c
> /Users/beazley/Code/splitter.py(18)split()
-> fields = line.split(delimiter)
(Pdb)
配置:.pdbrc
其他参考文章:http://blog.chinaunix.net/u2/60913/showart_1665075.html
http://blog.csdn.net/magicbreaker/archive/2009/01/11/3754733.aspx