views:

363

answers:

2

Is there any other way to debug swig extensions except for doing

gdb python stuff.py

?

I have wrapped the legacy library libkdtree++ and followed all the swig related memory managemant points (borrowed ref vs. own ref, etc.). But still, I am not sure whether my binding is not eating up memory. It would be helpful to be able to just debug step by step each publicized function: starting from Python then going to via the C glue binding into C space, and returning back.

Is there already such a possibility?

Thanks,

wr

+1  A: 

Well, for debugging, you use a debugger ;-).

When debugging, it may be a good idea to configure Python with '--with-pydebug' and recompile. It does additional checks then.

If you are looking for memory leaks, there is a simple way:

Run your code over and over in a loop, and look for Python's memory consumption.

theller
What I meant is: is there a debugger that supports that switching of language boundaries? Like, pdb switches to gdb when entering the swig part.
wr
Not that I know of.
theller
+1  A: 

gdb 7.0 supports python scripting. It might help you in this particular case.

KOkon