pdb 常用命令
命令 解释
break 或 b 设置断点 设置断点
continue 或 c 继续执行程序
list 或 l 查看当前行的代码段
step 或 s 进入函数
return 或 r 执行代码直到从当前函数返回
exit 或 q 中止并退出
next 或 n 执行下一行 pp 打印变量的值
help 帮助
(Pdb) s
--Call--
> c:\users\wuchan4x\desktop\eilinge\unit_tests_dump\pbd_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:\users\wuchan4x\desktop\eilinge\unit_tests_dump\pbd_test02.py:6
(Pdb) b 3
Breakpoint 2 at c:\users\wuchan4x\desktop\eilinge\unit_tests_dump\pbd_test02.py:3
(Pdb) b
Num Type Disp Enb Where
1 breakpoint keep yes at c:\users\wuchan4x\desktop\eilinge\unit_tests_dump\pbd_test02.py:6
2 breakpoint keep yes at c:\users\wuchan4x\desktop\eilinge\unit_tests_dump\pbd_test02.py:3
(Pdb) c
> c:\users\wuchan4x\desktop\eilinge\unit_tests_dump\pbd_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:\users\wuchan4x\desktop\eilinge\unit_tests_dump\pbd_test02.py(6)pdb_test() -> print(i) (Pdb) 0 > c:\users\wuchan4x\desktop\eilinge\unit_tests_dump\pbd_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:\users\wuchan4x\desktop\eilinge\unit_tests_dump\pbd_test02.py(6)pdb_test() -> print(i) (Pdb) 1 > c:\users\wuchan4x\desktop\eilinge\unit_tests_dump\pbd_test02.py(5)pdb_test() -> for i in range(arg): (Pdb) n > c:\users\wuchan4x\desktop\eilinge\unit_tests_dump\pbd_test02.py(6)pdb_test() -> print(i) (Pdb) 2 > c:\users\wuchan4x\desktop\eilinge\unit_tests_dump\pbd_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:\users\wuchan4x\desktop\eilinge\unit_tests_dump\pbd_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:\users\wuchan4x\desktop\eilinge\unit_tests_dump\pbd_test02.py:5 (Pdb) condition 2 i==3 (Pdb) b Num Type Disp Enb Where 1 breakpoint keep yes at c:\users\wuchan4x\desktop\eilinge\unit_tests_dump\pbd_test02.py:6 2 breakpoint keep yes at c:\users\wuchan4x\desktop\eilinge\unit_tests_dump\pbd_test02.py:3 stop only if i==3 3 breakpoint keep yes at c:\users\wuchan4x\desktop\eilinge\unit_tests_dump\pbd_test02.py:5 (Pdb) a arg = 5