I have downloaded and compiled Python 3.5 on a CentOS 6.5 machine. It works without problems. The problem is I have to use gdb
to debug a subtle bug involving cpu overuse during my python program execution.
From official Python documentation about gdb extension, they says the only thing to do is to add
add-auto-load-safe-path /path/to/dir/with/python-gdb.py
to ~/.gdbinit
. I tested it with
gdb --args /path/to/python3.5/binary (gdb) py-bt
but I get
Undefined command: "py-bt"
gdb
is version 7.2 and have python support enabled.
A set of GDB macros are distributed with Python that aid in debugging the Python process. You can install them by adding the contents of Misc/gdbinit in the Python sources to ~/. gdbinit -- or copy it from Subversion.
Explanation. GDB embeds the Python interpreter so it can use Python as an extension language. You can't just import gdb from /usr/bin/python like it's an ordinary Python library because GDB isn't structured as a library. What you can do is source MY-SCRIPT.py from within gdb (equivalent to running gdb -x MY-SCRIPT.py ) ...
Basing on blog post by Debugging of CPython processes with gdb One more way to resolve the issue is to source python3.5-gdb.py
file. Run command info auto-load
to check that files are loaded (if so) and if not -- load it manually: source /usr/share/gdb/auto-load/usr/bin/python3.5-gdb.py
(! path may be different).
Then py-bt
should work!
EDITED: changed py version
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With