What is it
pdbx: A remote pdb debugger base on pdb. It's:
- be compatible with pdb
- remote debug supported
- xq/xquit commands supported
- quit safely from debugger, the program being executed is continued(not abored)
- redebug supported
- suspend mode supported
软件介ç»
pdbx: 一款基于pdb的远程pdb调试工具,主è¦ç‰¹æ€§æœ‰ï¼š
- 和pdb完全兼容
- 支æŒè¿œç¨‹è°ƒè¯•功能
- 支æŒxq/xquit命令
- 安全退出命令: 使用xq/xquit退出调试,执行的Pythonè„šæœ¬ä¼šç»§ç»æ‰§è¡Œï¼Œè€Œä¸ä¸æ–退出(对q/quit命令的改善)
- 支æŒé‡å¤è°ƒè¯•
- 支æŒsuspend模å¼
- 强制或者éžå¼ºåˆ¶è¿›å…¥æ–点
Installing pdbx
- Download pdbx from https://code.google.com/p/stonelab/downloads/list or https://pypi.python.org/pypi
- Unpack the archive
- tar xvf pdbx-x.x.x.tar.gz
- Install pdbx
- sudo python setup.py install
安装pdbx
- 从https://code.google.com/p/stonelab/downloads/list 或者 https://pypi.python.org/pypi下载pdbx
- 解压压缩包
- tar xvf pdbx-x.x.x.tar.gz
- 安装pdbx
- sudo python setup.py install
How to use pdbx
- Add pbdx in python scripts
from pdbx import Rpdb
rpdb = Rpdb() # Debugger started. Port is 8787(Default Value), Suspend is True(Default Value)
rpdb = Rpdb(9898) # Debugger started. Port is 9898(Specified Value), Suspend is True(Default Value)
rpdb = Rpdb(suspend=False) # Debugger started. Port is 8787(Default Value), Suspend is False(Specified Value)
rpdb = Rpdb(9898, False) # Debugger started. Port is 9898(Specified Value), Suspend is False(Specified Value)
rpdb.set_trace()
- Remote debug with telnet
telnet xxx.xxx.xxx.xxx 8787
- Interact with pdb commands
Documented commands (type help <topic>):
========================================
EOF bt cont enable jump pp run unt xq
a c continue exit l q s until xquit
alias cl d h list quit step up
args clear debug help n r tbreak w
b commands disable ignore next restart u whatis
break condition down j p return unalias where
xq/xquit are new commands in pdbx
it's used to quit safely from debugger, the program being executed is continued(not abored)
- Re-Remote debug with telnet
如何使用pdbx
- 在pythonè„šæœ¬ä¸æ·»åŠ pdbx代ç ,设置æ–点
from pdbx import Rpdb
rpdb = Rpdb() # å¯åŠ¨è°ƒè¯•ï¼Œé»˜è®¤ç«¯å£8787,强制æ–点
rpdb = Rpdb(9898) # å¯åŠ¨è°ƒè¯•ï¼ŒæŒ‡å®šç«¯å£9898,强制æ–点
rpdb = Rpdb(suspend=False) # å¯åŠ¨è°ƒè¯•ï¼Œé»˜è®¤ç«¯å£8787,éžå¼ºåˆ¶æ–点
rpdb = Rpdb(9898, False) # å¯åŠ¨è°ƒè¯•ï¼ŒæŒ‡å®šç«¯å£9898, éžå¼ºåˆ¶æ–点
rpdb.set_trace()
- 通过telnet,进入远程调试
telnet xxx.xxx.xxx.xxx 8787
- 使用pdb命令,进入调试交互状æ€
Documented commands (type help <topic>):
========================================
EOF bt cont enable jump pp run unt xq
a c continue exit l q s until xquit
alias cl d h list quit step up
args clear debug help n r tbreak w
b commands disable ignore next restart u whatis
break condition down j p return unalias where
xq/xquit是pdbxæ–°åŠ çš„å‘½ä»¤
使用安全退出模å¼ï¼Œæ‰§è¡Œxq/xquit,远程python脚本自动è¿è¡Œï¼Œè€Œéžè¢«å¼ºåˆ¶ä¸æ–退出,是对pdb q/quit命令的改善。
- é‡å¤è°ƒè¯•
- 使用telnet冿¬¡è¿›å…¥è°ƒè¯•状æ€
Release Notes
- V0.1.0
- remote debug supported
- V0.2.0
- xq/xquit supported
- redebug supported
- suspend mode supported
- add setup.py
å‘布说明
- V0.1.0
- 支æŒè¿œç¨‹è°ƒè¯•模å¼
- V0.2.0
- 支æŒxq/xquit命令:安全退出模å¼
- 支æŒé‡å¤è°ƒè¯•
- 支æŒsuspend模å¼
- æ·»åŠ setup.py脚本
Author Info
sample(演示)
telnet 127.0.0.1 8787
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
--Return--
> /Library/Python/2.7/site-packages/pdbx/pdbx.py(133)set_trace()->None
-> Pdb.set_trace(self, frame=frame)
(Pdb) n
> /Users/stone/Tmp/sample.py(25)main()
-> rpdb.set_trace()
(Pdb) n
> /Users/stone/Tmp/sample.py(26)main()
-> i = random.randint(1, 10)
(Pdb) l
21 # rpdb = Rpdb(9898) # Debugger started. Port is 9898(Specified Value), Suspend is True(Default Value)
22 # rpdb = Rpdb(suspend=False) # Debugger started. Port is 8787(Default Value), Suspend is False(Specified Value)
23 # rpdb = Rpdb(9898, False) # Debugger started. Port is 9898(Specified Value), Suspend is False(Specified Value)
24 while True:
25 rpdb.set_trace()
26 -> i = random.randint(1, 10)
27 j = random.randint(1, 10)
28 r = add(i, j)
29 print r
30 time.sleep(1)
31
(Pdb) b 29
Breakpoint 2 at /Users/stone/Tmp/sample.py:29
(Pdb) c
> /Users/stone/Tmp/sample.py(29)main()
-> print r
(Pdb) p r
9
(Pdb) help xq
xq(uit) - Quit safely from the debugger.
The program being executed is continued(not abored).
(Pdb) xq
Connection closed by foreign host.