benibenj / vscode-pythonCpp

A Visual Studio Code Debug Extension for debugging mixed Python and C++ code. The extension starts a Python debug session and attaches the C++ debugger to it. This extension is useful for debugging Python programs that call functions from shared libraries (.so/.dll).
Other
47 stars 7 forks source link

Attaching python to C++ instead #11

Open KevinKBytes opened 1 year ago

KevinKBytes commented 1 year ago

Hi,

Could I get this extension to work if say, I have cpp files which call python functions from .so files?

Regards, Kevin

benibenj commented 1 year ago

Hi @KevinK-byte, this is currently not possible with the Python C++ Debugger extension.

KevinKBytes commented 1 year ago

What about c++ files which call shared library files, which then call into normal .py files? Would I at least be able to break into the py files?

benibenj commented 1 year ago

What the extension does is it starts a Python debugger and attaches a C++ debugger to it and can't do it the other way around. Because the python debugger launches first, the entry point of the code/debugger has to be a Python script.

jokerwb commented 1 year ago

I have the following set up:

Can I use this debugger to step through the **.cpp to debug C++ run?

eclazi commented 1 year ago

+1 for this. Would love to use it to debug embedded python interpreter in a C++ application

benibenj commented 1 year ago

I'm open to adding this feature. I've never run into this situation, can you create an example code (python, c++ and compiler flags) for me to test with? Have you tried manually starting the python and c++ debuggers and attaching them to each other? If so how did you manage that?

eclazi commented 1 year ago

You can launch the application with the embedded interpreter under the c++ debugger, then change launch config and launch the python debugger but attach to a process id via selection, and select the application.

vscode allows you to debug multiple things at the same time.

I have an application which is written in C++ however the GUI is written in python and calls C++ bindings to the core app