linux下pdb的使用

来源:互联网 发布:sass node.js 编辑:程序博客网 时间:2024/05/16 07:47

之前一直用print的方法来调试问题,不过这种方法在出现比较异常的问题的时候还是比较麻烦的。

所以今天用了下pdb的调试方法。

用法其实比较简单的,和gdb差不多。

1.运行

    python -m pdb ***.py [参数]

2.进入调试界面

    (Pdb) 

这里可以用h来查看可用的命令

Documented commands (type help <topic>):========================================EOF break commands debug h l pp s up a bt condition disable help list q step w alias c cont down ignore n quit tbreak whatisargs cl continue enable j next r u where b clear d exit jump p return unaliasMiscellaneous help topics:==========================exec pdbUndocumented commands:======================retval rv

 

主要用到的解释下:

b||break 

        显示已有断点和设置断点

        设置断点的时候,一般用 b xx(行)  和 b xx.py(文件名):yy(行)

 

        r

        运行到断点处

 

        n || next 

        下一步

 

        s|| step

        相当于step in(这里有问题,我用stepin无论如何都无法进入到函数里面去,不知道为什么)所以只要采用

        到这个函数的时候,list一下,再break一下。

 

        p

        相当于display

 

这么多,大概差不都就能用了。