Debug Python / C ++ mixed code in Eclipse

I have a C ++ project with a SWIG-created Python interface that I create with CMake. Now I'm trying to find a convenient way to debug my mixed Python / C ++ code. I can get the error stack trace using gdb, but I would like to have some more attractive features, such as the ability to execute code and set breakpoints, for example, using Eclipse.

Using the Eclipse generator for CMake, I can generate a project that I can import into Eclipse. This works great, and I can also go through clean C ++ executables. But then the problem begins.

First of all, I cannot build a Python interface from within Eclipse. From the command line, I just do "make python", but there is no "python" in the Eclipse project.

Secondly, as soon as I compiled the Python interface, I don’t know how to get through the Python script containing the calls for my wrapped C ++ classes. Eclipse has debugging for both Python and C ++, but can they be combined?

+6
source share
1 answer

several more attractive features, such as the ability to execute code and set breakpoints, for example using Eclipse

how are these features "fancy"? You can already do this in pdb for Python or gdb for C ++.

I would suggest running python code using pdb (or using pdb.set_trace() to interrupt execution at an interesting point) and attach gdb to the process in a separate terminal. Use pdb to set breakpoints and execute your Python code. Use gdb to set breakpoints and execute your C ++ code. When pdb makes its own call, gdb will prevail. When gdb continue allows Python to resume execution, pdb will take over.

This should allow you to jump between C ++ and Python breakpoints without having to trace through the interpreter.


Disclaimer: I basically think the IDE is junk software, so if Eclipse really has a good way to integrate this, I still don’t know about it.

+2
source

All Articles