scons on win32:使用pdb调试SConstruct

时间:2013-07-30 21:23:46

标签: python windows scons pdb

我正在尝试调试一个SConstruct文件,该文件深陷到一些不起眼的函数中,我想逐步完成代码。这是我试图做的,但失败了:

$ python -m pdb `which scons.py`
> c:\python27\scripts\scons.py(26)<module>()
-> __revision__ = "src/script/scons.py 5357 2011/09/09 21:31:03 bdeegan"
(Pdb) b SConstruct:10
***  'SConstruct' not found from sys.path
(Pdb) import sys, os
(Pdb) sys.path.append(os.getcwd())
(Pdb) b SConstruct:10
***  'SConstruct' not found from sys.path
(Pdb)

如果我将SConstruct重命名为SConstruct.py,它会成功设置断点,但当然它不起作用,因为“scons”加载SConstruct,而不是SConstruct.py。 有什么方法可以强制python在那里放置一个断点吗?

我是从Win7系统上的msys bash控制台运行的。 Python版本:

$ python
Python 2.7.2 (default, Jun 12 2011, 15:08:59) [MSC v.1500 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.

1 个答案:

答案 0 :(得分:2)

Debugging SCons wiki page上有一些提示。具体做法是:

scons --debug=pdb <args...>
# from the wiki example: you can set a breakpoint on a file relative to sys.path
(Pdb) b SCons/Tool/msvc.py:158 
# you can set a breakpoint in the SConstruct file with the full path
(Pdb) b /Users/me/code/project/SConstruct:10