vscode-pythonCpp icon indicating copy to clipboard operation
vscode-pythonCpp copied to clipboard

Attaching python to C++ instead

Open KevinKBytes opened this issue 3 years ago • 7 comments

Hi,

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

Regards, Kevin

KevinKBytes avatar Aug 21 '22 02:08 KevinKBytes

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

benibenj avatar Aug 21 '22 12:08 benibenj

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?

KevinKBytes avatar Aug 23 '22 07:08 KevinKBytes

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.

benibenj avatar Aug 23 '22 07:08 benibenj

I have the following set up:

  • WSL2 and calls up vscode from the terminal console to instal VC Code Server
  • vscode with the extension needed (python, C/C++ and this debugger)
  • python script contains parameters needed as input into the C++
  • python script calls the complied **.o file with the parameters in the WSL2 terminal
  • python file is in the same folder as the .cpp/.h/**.o files

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

jokerwb avatar Sep 30 '22 20:09 jokerwb

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

dev-joss avatar Jan 11 '23 03:01 dev-joss

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?

benibenj avatar Feb 15 '23 09:02 benibenj

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

dev-joss avatar Feb 15 '23 19:02 dev-joss