我习惯了GDB,b那在哪里。
但在其中pdb,b 只需列出断点。
我可以b 123,但懒得打字123。
也许像一个神奇的论点b .?
我知道 PyCharm 和__import__('pdb').set_trace(),只是检查这些快速调试是否有可用的 CLI 替代方案。
如果您接受添加新pdb命令,这很简单:
def do_breakcurrent(self, arg):
cur_lineno = str(self.curframe.f_lineno)
return self.do_break(cur_lineno)
import pdb
pdb.Pdb.do_breakcurrent = pdb.Pdb.do_bc = do_breakcurrent
使用breakcurrent或bc:
(Pdb) bc
Breakpoint 1 at /Users/georgexsh/workspace/so/52110534.py:11
如果您想将这些代码放入.pdbrc以使其自动可用,只需稍作调整:
import pdb
pdb.Pdb.do_bc = lambda self,arg: self.do_break(str(self.curframe.f_lineno))