gpt4 book ai didi

python - 当我使用调试版本的 Python 时如何使用 gdb?

转载 作者:太空宇宙 更新时间:2023-11-04 03:51:52 26 4
gpt4 key购买 nike

我的 gdb 版本链接到我的系统 python,但我目前正在使用一个特殊的 python 调试版本。因此,gdb 无法正确启动,出现如下错误:

$ gdb
gdb: Symbol `_Py_ZeroStruct' has different size in shared object, consider re-linking
gdb: Symbol `PyBool_Type' has different size in shared object, consider re-linking
gdb: Symbol `_Py_NotImplementedStruct' has different size in shared object, consider re-linking
gdb: Symbol `PyFloat_Type' has different size in shared object, consider re-linking
gdb: Symbol `_Py_TrueStruct' has different size in shared object, consider re-linking
gdb: Symbol `_Py_NoneStruct' has different size in shared object, consider re-linking
Segmentation fault

...或者可能是这样的错误:

gdb: symbol lookup error: gdb: undefined symbol: PyUnicodeUCS4_FromEncodedObject

即使 LD_LIBRARY_PATH 上存在非系统版本的 Python,我如何使用 gdb?

最佳答案

我在 rootpy Documentation 中找到了答案:

The way around this is to preload the correct library by setting LD_PRELOAD, and then unsetting it before your program is executed. For example, this will debug my-program-to-debug:

LD_PRELOAD=/usr/lib/libpython2.7.so gdb -ex 'set environ LD_PRELOAD' --args my-program-to-debug

Note that you need to set LD_PRELOAD to the right version of python that gdb was compiled against, which you can find with ldd $(which gdb) from a fresh environment.

关于python - 当我使用调试版本的 Python 时如何使用 gdb?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20951429/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com