Commit f9ae1831 authored by Kirill Smelkov's avatar Kirill Smelkov

pyinject.gdb: GDB commands to inspect Python processes by injecting/running Python code

parent ac28b90c
# pyinject.gdb provides GDB commands to inject code into Python processes.
# see also: https://pyrasite.readthedocs.io/
# xpyrun "<code>" runs python <code>.
define xpyrun
set $_gstate = (int)PyGILState_Ensure()
set $_unused_int = (int)PyRun_SimpleString($arg0)
set $_unused_void = (void)PyGILState_Release($_gstate)
end
# xpybt prints python-level backtrace to program stdout.
define xpybt
xpyrun "import traceback; traceback.print_stack()"
end
# xpymemtop prints top py-memory usage to program stdout.
define xpymemtop
xpyrun "import objgraph; objgraph.show_most_common_types()"
end
# vim: ft=gdb
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment