Demo of debugging hybrid C++/Python project using two debuggers (Xcode and PyCharm).
It uses remote debugging feature, which is supported only in Profession Edition of PyCharm.
You'll need PyCharm Profession Edition, Python 3.6, NumPy and Boost. I've been using Xcode as C++ debugger, but any other C++ debugger/IDE should work as well.
I've used MacPorts for installing Python, NumPy and Boost:
sudo port install python36
sudo port install py36-numpy
sudo port install boost +no_single +no_static +python36
Note
When installing Boost
with MacPorts
, Boost.Python.NumPy
won't be installed unless NumPy
was previously installed using MacPorts
.
- Open project in PyCharm and create a run/debug configuration for remote debugging pointing to
localhost:5678
. - Start PyCharm's debugger first.
- Open project in Xcode and run it.
- C++ app will get stuck when starting
pydevd
on this line and PyCharm debugger will get activated. - Put a breakpoint in a loop in fibonacci.py and continue execution in PyCharm.
- In PyCharm's debugger set value of
stop
toTrue
to exit from the loop. - Unfortunately, PyCharm does not allow to set a Python breakpoint in C++ code, but if you leave from the last Python fragment using Step Over, then Python debugger will get activated when you enter next Python fragment.
- Continue running the code, and it will create a tiny 2x3 gray scale image in
~/foo.png
.