10

我刚刚gdb 7.8在运行 linux 的服务器机器上从我的主目录中的源代码编译。我以前一直在使用gdb 7.6,除了gdb自身的稳定性问题(升级的原因)之外,一切正常。

自升级以来gdb,当我运行时,cgdb 0.6.7我立即收到以下消息:

Python Exception <type 'exceptions.ImportError'> No module named gdb:

warning:
Could not load the Python gdb module from `/home/username/bin/gdb//python'.
Limited Python support is available from the _gdb module.
Suggest passing --data-directory=/path/to/gdb/data-directory.

当我建造gdb时,我使用了./configure --with-python.

当我运行cgdb并且我的程序遇到段错误时,我输入backtrace并收到以下消息:

Python 异常没有名为 gdb.frames 的模块:

所以看起来我实际上无法在没有python支持的情况下使用gdb/ 。cgdb我能做些什么来解决这个问题?

FWIW;我不使用python,我通常写c++

4

4 回答 4

17

您应该指定“ --data-directory”的值。例如,如果你gdb从构建目录加载,命令应该是:

./gdb -data-directory ./data-directory

然后gdb可以知道在哪里可以找到python模块。

你可以参考这个讨论

于 2014-09-01T08:21:56.697 回答
3
root@labs:~/gdb-8.1# gdb --version
Python Exception <type 'exceptions.ImportError'> No module named gdb: 
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.
....

尝试将 python lib cp 到 --data-directory= /path/to/gdb/data-directory。我的数据目录是/usr/local/share/gdb/python

# mkdir -p /usr/local/share/gdb/python/gdb
# cp -rf ~/gdb-8.1/gdb/python/lib/gdb/* /usr/local/share/gdb/python/gdb/


# gdb --version
GNU gdb (GDB) 8.1
Copyright (C) 2018 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-pc-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word".
于 2018-05-05T08:29:08.977 回答
2

我刚遇到这个,想分享我发现的东西。在编译过程中,特别是“make install”步骤,我注意到了这条消息:

WARNING: `makeinfo' is missing on your system.  You should only need it if
         you modified a `.texi' or `.texinfo' file, or any other file
         indirectly affecting the aspect of the manual.  The spurious
         call might also be the consequence of using a buggy `make' (AIX,
         DU, IRIX).  You might want to install the `Texinfo' package or
         the `GNU make' package.  Grab either from any GNU archive site.

听起来好像我没有 可以makeinfo,但实际上它导致了 OP 询问的错误。安装后,texinfo我重新运行make install并运行gdb,没有 python 错误消息。

于 2018-12-18T16:09:58.453 回答
0

只需完成上述回复:

可能您已将可执行gdb复制到/usr/local/bin(这是我优先考虑我安装为默认 shell gdb的最新 gdb 的方式,同时防止与默认 Ubuntu 的gdb混淆)。然后你应该考虑你必须将数据目录参数从原始位置提供给你复制的那个/usr/local/bin。所以那将是:

/usr/local/bin/gdb --data-directory=/path_to_fully_installed_gdb_folder/data-directory

PS:我在Ubuntu 16.04上为gdb-8.1做了这个

于 2018-06-02T02:36:46.557 回答