6

I got a quite complex distributed programming framework where there are:

  1. a Controller, BC, written in Python as a twisted plugin, which is running on some machine;
  2. N Daemons, BM, written in Python but wrapping a C++ core as a shared library, in the following way:

import imp handle = imp.load_dynamic('mylib', '../libmy.so')

Then each BM talks to the BC via a jsonrpc interaction, but we don't care about this.

What I would do is to debug, possibly in a step into/step over/step debug fashion but not limited to, a BM process, which at the front-end appears as a homogeneous stream of characters in a single terminal.

I'm strongly interested into the C++ part, considering the Python code almost final to release and working well.

Due to this language mixture I'm a bit confused about what type of tool may be useful.

3
  • No they can't. Daemons are actually Python code which calls few but essential APIs from C++ library mentioned above. Commented Apr 20, 2015 at 14:31
  • Ah, I'd missed that nuance; apologies. Commented Apr 20, 2015 at 14:32
  • Well in facts I could build a C++ outer executable representing the work done by Python daemon; but the answer from WakkaDojo reduces the problem to what we're talking about :-) Commented Apr 20, 2015 at 14:38

1 Answer 1

4

You can use gdb on any C/C++ extensions loaded through Python. The way this is done is:

(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. Tip from boost::python docs

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.