gdb可以调试python的pdb么

1.如题:

gdb可以调试python的pdb么?

答案:可以,实验如下。

 

2.实验:

生成一个a.py代码文件,代码如下:

import pdb

a = 1
print "111",a
pdb.set_trace()
a = 2
print "222",a

 

gdb python

(gdb) b main
Breakpoint 1 at 0x400770: file ./Modules/python.c, line 23.
(gdb) b exit
Function "exit" not defined.
Make breakpoint pending on future shared library load? (y or [n]) y
Breakpoint 2 (exit) pending.

Breakpoint 2 (exit) pending.
(gdb) r a.py

Breakpoint 1, main (argc=2, argv=0x7fff6d9883f8) at ./Modules/python.c:23
23 ./Modules/python.c: No such file or directory.
in ./Modules/python.c =====================(到达main断点)

(gdb) c =====================(继续执行)
Continuing.
111 1
> /home/users/dodng/tmp/a.py(6)<module>()
-> a = 2
(Pdb) p a =====================(到达pdb断点,用pdb查看变量a的值)
1
(Pdb) n =====================(用pdb next)
> /home/users/dodng/tmp/a.py(7)<module>()
-> print "222",a

(Pdb) c
222 2

Breakpoint 3, 0x0000003f0b030c00 in exit () from /lib64/tls/libc.so.6
(gdb) bt =====================(到达exit断点)
#0 0x0000003f0b030c00 in exit () from /lib64/tls/libc.so.6
#1 0x0000003f0b01c4c2 in __libc_start_main () from /lib64/tls/libc.so.6
#2 0x00000000004006da in _start ()

 

posted @ 2016-11-10 13:50  dodng  阅读(1067)  评论(0编辑  收藏  举报