How should I structure my C++ program so I can use PyCharm to debug my Python code?

I am updating my original question to be more specific.

Can I write a Python program that will let me run my C++ program and then tell PyCharm to remote-debug it? I could then have a project consisting of Python files, invoked by my program, that PyCharm would debug, set breakpoints, etc?

The genesis of the idea is this stackoverflow post which makes me think I can use PyCharm to debug my own code:


Original post

I need some guidance before I end up wasting too much time with something that will never work.

I have a server C++ program that:
  • Initializes itself from some disk files
  • Reads commands over the network (various TCP/IP protocols some of which are really obscure.)
  • Calls Python to allow customers to attach their own custom actions

I'd like to add a PyCharm plug-in to allow specialized editing of the initialization data (nodes and links in a mesh network where a graphical editor would be a huge help.)

How should I structure this?

Option 1 might be to make a Python program that calls into C++ to initialize, and the C++ event loop. If the same interpreter is used in the C++ code then if it hits Python code with a breakpoint it should stop and allow source level debugging.

Option 2 is a C++ program and somehow when the embedded Python is run it does so in the debugger

Option 3?

Could I package the remote debugger capability of PyCharm into a server and still do remote debugging with it in case something goes wrong? This is a pretty powerful feature of Java and it seems that this may also be present in PyCharm.


Please sign in to leave a comment.