Reputation: 18182
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
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
?
Upvotes: 4
Views: 3942
Reputation: 18182
I found the answer in the 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.
Upvotes: 3