pythonc++visual-studio-codevisual-studio-debugging

Debugging Python C++ extension from Visual Studio Code on Linux


I have written some python C++ extension that I want to debug while running it from python (interactively) using Visual Studio Code on Linux.

I have set-up my launch.json as follows for attach. Basically it is using my python interpreter as the program

    { 
        "name": "(gdb) Attach",
        "type": "cppdbg",
        "request": "attach",
        "program": "/home/mike/.pyenv/versions/anaconda3/bin/python",
        "processId": "${command:pickProcess}",
        "MIMode": "gdb",
        "setupCommands": [
            {
                "description": "Enable pretty-printing for gdb",
                "text": "-enable-pretty-printing",
                "ignoreFailures": true
            }
        ]
    },

Unfortunately, nothing happens. I am pretty new to Visual Studio Code for debugging, so I might be missing something trivial.


Solution

  • It was indeed trivial. Just attach the correct process. Keeping the answer here as it is not trivial to find on the web.