My version of gdb is linked against my system python, but I am currently working with a special debug build of python. Hence, gdb fails to launch correctly, with errors like this:
我的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
...or maybe errors like this:
…或者像这样的错误:
gdb: symbol lookup error: gdb: undefined symbol: PyUnicodeUCS4_FromEncodedObject
How can I use gdb even though a non-system version of Python exists on my LD_LIBRARY_PATH
?
即使在LD_LIBRARY_PATH上存在一个非系统版本的Python,我如何使用gdb呢?
1 个解决方案
#1
2
I found the answer in the rootpy Documentation:
我在rootpy文档中找到了答案:
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来预加载正确的库,然后在程序执行之前将其取消。例如,这将调试my-program- 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.
注意,您需要将LD_PRELOAD设置为对gdb所编译的python的正确版本,您可以从新的环境中找到ldd $(gdb)。
#1
2
I found the answer in the rootpy Documentation:
我在rootpy文档中找到了答案:
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来预加载正确的库,然后在程序执行之前将其取消。例如,这将调试my-program- 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.
注意,您需要将LD_PRELOAD设置为对gdb所编译的python的正确版本,您可以从新的环境中找到ldd $(gdb)。