简体   繁体   中英

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.

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

You could also use the VScode extension "Python C++ Debug". It automatically attaches the C++ debugger to the python debugger for you. Also if you don't have a launch.json file ready, it sets up all configurations you need when clicking on 'create a launch.json file'.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM