如何修复“此版本的GDB不支持Python脚本”
这个 configure
脚本是这样启动的:
./configure --with-python=yes --host=arm-linux-gnueabi
所以,Python 是启用的。而且在 configure 脚本的日志 中,我没有发现任何与 Python 有关的问题。不过,不管怎样,编译后的 gdb 还是一直提示:
$ ./gdb -q
/home/constantine/.gdbinit:7: Error in sourced command file:
ind_string_in_backtrace (gdb.Function)::1: Error in sourced command file:
Undefined command: "class". Try "help".
(gdb) py print("hello")
Python scripting is not supported in this copy of GDB.
我在 gdb 中看到的错误也是关于 Python 的 (就是那个在自动启动时加载的脚本)。我尝试过 make clean
,但没有帮助。我希望有人知道解决办法,我真的需要脚本功能,因此需要用到 Python。
1 个回答
2
你可能在你的构建机器上缺少Python开发库(在Ubuntu上是python-dev包或类似的东西,在CentOS上是python-devel)。
在配置gdb的时候,gdb的顶层配置日志里没有提到Python。
试着这样构建:
make 1> out.log 2> err.log然后在out.log里搜索Python。你应该能看到一些类似这样的内容,这样才能让Python脚本正常工作。
checking whether to use python... auto checking for python... /usr/bin/python checking for python2.7... yes checking compiler flags for python code... -fno-strict-aliasing -DNDEBUG -fwrapv checking whether python supports threads... yes