2011年3月30日

pdb - gdb like , python online debugger module

ref : http://pythonconquerstheuniverse.wordpress.com/category/the-python-debugger/

用這個 module 後,就可以像 gdb 一樣對 python code 作單步執行。
但是 python 是直譯式語言,所以要修改 code...
大概就是:
  1. import pdb
  2. 在要開始 trace 的地方加入 pdb.set_trace()

這樣 執行到 pdb.set_trace( ) 這一行,就會中斷,出現 (Pdb) 的 promt,要你輸入command。
用 help 可以顯示一些 ..
(Pdb) help

Documented commands (type help <topic>):
========================================
EOF bt cont enable jump pp run unt
a c continue exit l q s until
alias cl d h list quit step up
args clear debug help n r tbreak w
b commands disable ignore next restart u whatis
break condition down j p return unalias where

Miscellaneous help topics:
==========================
exec pdb

Undocumented commands:
======================
retval rv

沒有留言:

張貼留言