How to attach gdb to python subprocess in VS code

Viewed 170

I have a python script that calls a c++ binary and would like to debug its source code in VS Code:

proc = subprocess.Popen( Command, shell=True    ,
                         stdout=sys.stdout      , 
                         stderr=subprocess.PIPE  )
return_code = proc.wait()
message = proc.stderr.read().decode()

So I look up the python debugger's PID, and do the following GDB attach:

{
            "name": "(gdb) Attach",
            "type": "cppdbg",
            "request": "attach",
            "program": "/My/virtual/env/bin/python",
            "stopAtEntry": true,
            "processId": "${command:pickProcess}",
            "MIMode": "gdb",
            "setupCommands": [
                {
                    "description": "Enable pretty-printing for gdb",
                    "text": "-enable-pretty-printing",
                    "ignoreFailures": true
                }
            ],
            "miDebuggerPath": "/usr/bin/gdb",
        },

VS code calls pkexec and attaches gdb, or so it seems, however, if I continue the python script, the c++ code doesn't get caught.

Could sb tell me what the problem is or how I could solve it?

0 Answers
Related