我試圖編譯GDB與Python的支持,所以我可以用在所提供的PrettyPrinters: http://gcc.gnu.org/svn/gcc/trunk/libstdc++-v3/pythonGDB Python支持,導入錯誤沒有模塊名爲GDB
我從網上下載(http://ftp.gnu.org/gnu/gdb/gdb-7.6.1.tar.gz)的最新GDB源和編譯它我的Centos 6.4如下:1. --with的./configure的Python 2.使
我需要提供一個路徑或其他參數--with-蟒蛇的路徑到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.
有人可以幫我解決這個問題?
Tom,gdb獲取的系統與其實際使用的系統(我們將其打包)不同。在這種情況下,--data-directory應該指向什麼?我之前沒有使用過這個選項,所以不知道直接到底是哪一個? – alphabit
可能更重要的是正確設置--with-separate-debug-dir。在CentOS上,我想/ usr/lib/debug是正確的。您可能還想將/ usr/share/gdb中的一些內容符號鏈接到安裝樹中;也許只是/ usr/share/gdb/auto-load。但是如果你將它打包成RPM,那麼你可能應該從官方的SRPM開始,然後從那裏開始。 –