How to debug a python program - C ++
I have a rather complex distributed programming structure where there is:
- a Controller,
BC
written in Python as a plugintwisted
that runs on some machine; - N Daemons,
BM
written in Python but wrapping up the C ++ core as a shared library like this:
import imp
handle = imp.load_dynamic('mylib', '../libmy.so')
Then everyone BM
interacts with BC
through interaction jsonrpc
, but we don't care.
What I would do is debug, perhaps step by step in / step over / step debug, but not limited to, a process BM
that is displayed on the front-end as a homogeneous stream of characters in one terminal.
I am very interested in the C ++ part, considering the Python code is almost final to free and work well.
Due to this language mix, I am a little confused as to what type of tool might be useful.
source to share
You can use gdb on any C / C ++ extensions loaded via Python. How it's done:
(gdb) target exec python
(gdb) run
>>> import your_extension as ye
>>> ye.do_something ()
>>> # do your python here
>>> # or just run your python script from here
(gdb) do debugging stuff
You can also add breakpoints / do full C / C ++ debugging via gdb. Advice from boost :: python docs
source to share