<p>我正在尝试使用python支持编译gdb,以便可以使用提供的PrettyPrinters:
<a href="http://gcc.gnu.org/svn/gcc/trunk/libstdc++-v3/python" rel="nofollow">http://gcc.gnu.org/svn/gcc/trunk/libstdc++-v3/python</a></p>
<p>我从(<a href="http://ftp.gnu.org/gnu/gdb/gdb-7.6.1.tar.gz" rel="nofollow">http://ftp.gnu.org/gnu/gdb/gdb-7.6.1.tar.gz</a>)下载了最新的gdb源代码,并在Centos 6.4上编译如下:
1。/配置——使用python
2。制造</p>
<p>我是否需要提供一个路径或另一个参数——使用python,路径是python libs或可执行文件?</p>
<p>在运行gdb进行编译后,我看到以下警告:</p>
<pre><code>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.
</code></pre>
<p>这里的异常很明显,我接下来要做的任何事情都将失败,因为它需要gdb模块,但无论如何我都试过了。所以我在~/.gdbinit中添加了以下行:</p>
<pre><code>import sys
sys.path.insert(0, '/tmp/pretty/python')
from libstdcxx.v6.printers import register_libstdcxx_printers
register_libstdcxx_printers (None)
</code></pre>
<p>现在,当我启动gdb时,我得到一个错误:</p>
<pre><code>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.
</code></pre>
<p>有人能帮我解决这个问题吗?</p>