pdb 常用命令
命令 解释
break 或 b 设置断点 设置断点
continue 或 c 继续执行程序
list 或 l 查看当前行的代码段
step 或 s 进入函数
return 或 r 执行代码直到从当前函数返回
exit 或 q 中止并退出
next 或 n 执行下一行 pp 打印变量的值
help 帮助
(Pdb) s
--Call--
> c:userswuchan4xdesktopeilingeunit_tests_dumppbd_test02.py(3)pdb_test()
-> def pdb_test(arg):
(Pdb) l
1 import pdb
2
3 -> def pdb_test(arg):
4 pdb.set_trace()
5 for i in range(arg):
6 print(i)
7 return arg
[EOF]
(Pdb) b 6
Breakpoint 1 at c:userswuchan4xdesktopeilingeunit_tests_dumppbd_test02.py:6
(Pdb) b 3
Breakpoint 2 at c:userswuchan4xdesktopeilingeunit_tests_dumppbd_test02.py:3
(Pdb) b
Num Type Disp Enb Where
1 breakpoint keep yes at c:userswuchan4xdesktopeilingeunit_tests_dumppbd_test02.py:6
2 breakpoint keep yes at c:userswuchan4xdesktopeilingeunit_tests_dumppbd_test02.py:3
(Pdb) c
> c:userswuchan4xdesktopeilingeunit_tests_dumppbd_test02.py(5)pdb_test()
-> for i in range(arg):
(Pdb) l
1 import pdb
2
3 def pdb_test(arg):
4 pdb.set_trace()
5 -> for i in range(arg):
6 print(i)
7 return arg
[EOF]
(Pdb) n > c:userswuchan4xdesktopeilingeunit_tests_dumppbd_test02.py(6)pdb_test() -> print(i) (Pdb) 0 > c:userswuchan4xdesktopeilingeunit_tests_dumppbd_test02.py(5)pdb_test() -> for i in range(arg): (Pdb) *** SyntaxError: invalid syntax (<stdin>, line 1) (Pdb) *** SyntaxError: invalid syntax (<stdin>, line 1) (Pdb) n > c:userswuchan4xdesktopeilingeunit_tests_dumppbd_test02.py(6)pdb_test() -> print(i) (Pdb) 1 > c:userswuchan4xdesktopeilingeunit_tests_dumppbd_test02.py(5)pdb_test() -> for i in range(arg): (Pdb) n > c:userswuchan4xdesktopeilingeunit_tests_dumppbd_test02.py(6)pdb_test() -> print(i) (Pdb) 2 > c:userswuchan4xdesktopeilingeunit_tests_dumppbd_test02.py(5)pdb_test() -> for i in range(arg): (Pdb) l 1 import pdb 2 3 def pdb_test(arg): 4 pdb.set_trace() 5 -> for i in range(arg): 6 print(i) 7 return arg [EOF] (Pdb) a arg = 5 (Pdb) p i 2 (Pdb) s > c:userswuchan4xdesktopeilingeunit_tests_dumppbd_test02.py(6)pdb_test() -> print(i) (Pdb) b (Pdb) l 1 import pdb 2 3 def pdb_test(arg): 4 pdb.set_trace() 5 for i in range(arg): 6 -> print(i) 7 return arg [EOF] (Pdb) b 5 Breakpoint 3 at c:userswuchan4xdesktopeilingeunit_tests_dumppbd_test02.py:5 (Pdb) condition 2 i==3 (Pdb) b Num Type Disp Enb Where 1 breakpoint keep yes at c:userswuchan4xdesktopeilingeunit_tests_dumppbd_test02.py:6 2 breakpoint keep yes at c:userswuchan4xdesktopeilingeunit_tests_dumppbd_test02.py:3 stop only if i==3 3 breakpoint keep yes at c:userswuchan4xdesktopeilingeunit_tests_dumppbd_test02.py:5 (Pdb) a arg = 5