【发布时间】:2013-09-27 08:04:07
【问题描述】:
我正在尝试使用 python 支持编译 gdb,以便可以使用以下提供的 PrettyPrinters: http://gcc.gnu.org/svn/gcc/trunk/libstdc++-v3/python
我从 (http://ftp.gnu.org/gnu/gdb/gdb-7.6.1.tar.gz) 下载了最新的 gdb 源并在我的 Centos 6.4 上编译如下: 1. ./configure --with-python 2.制作
我是否需要为 --with-python 提供路径或其他参数以及 python 库或可执行文件的路径?
编译后运行 gdb 时,我看到以下警告:
Python Exception <type 'exceptions.ImportError'> No module named gdb:
warning:
Could not load the Python gdb module from `/usr/local/share/gdb/python'.
Limited Python support is available from the _gdb module.
Suggest passing --data-directory=/path/to/gdb/data-directory.
这里的异常很明显,我接下来要做的任何事情都会失败,因为它需要 gdb 模块,但我还是试了一下。所以我在 ~/.gdbinit 中添加了以下几行:
import sys
sys.path.insert(0, '/tmp/pretty/python')
from libstdcxx.v6.printers import register_libstdcxx_printers
register_libstdcxx_printers (None)
现在当我启动 gdb 时,我得到了这个错误:
Traceback (most recent call last):
File "<string>", line 3, in <module>
File "/tmp/pretty/python/libstdcxx/v6/printers.py", line 18, in <module>
import gdb
ImportError: No module named gdb
Error while executing Python code.
有人可以帮我解决这个问题吗?
【问题讨论】: