Mixed mode debug of Python/C++?

Does anyone have experience with mixed mode debugging of Python and C++? I know about Visual Studio’s support for this, wondering if there are similar tools or flows for Linux? Google wasn’t much help in this regard. I tend to use pdb and print statements for debugging Python and gdb for debugging C++, but it sure would be nice to have a unified flow. How do you debug your TVM code that jumps between Python and C++?

1 Like

Hi, @brightmonkey , I have met the same question as you mentioned. As i know, there is no IDE that can cd-debug Python and C++ for TVM, are you sure that Visual Studio can do this?

I don’t usually get much need for both Python and C++ at the same time, but when I do I use the Python GDB plugin. I run it from VS Code using gdb against a specific Python file or test, from inside tvm.ci_cpu with python3-dbg installed, using these launch configurations:

{
    "name": "(gdb) Python Test",
    "type": "cppdbg",
    "request": "launch",
    "program": "/usr/bin/python3",
    "cwd": "${workspaceFolder:tvm}",
    "additionalSOLibSearchPath": "${workspaceFolder:tvm}",
    "MIMode": "gdb",
    "environment": [],
    "args": [
        "-m",
        "pytest",
        "-s",
        "${file}"
    ]
},
{
    "name": "(gdb) Python Script",
    "type": "cppdbg",
    "request": "launch",
    "program": "/usr/bin/python3",
    "cwd": "${fileDirname}",
    "additionalSOLibSearchPath": "${workspaceFolder:tvm}",
    "MIMode": "gdb",
    "args": [
        "${file}"
    ]
}

This means I can do fun things like use py-bt to follow the stack trace back into Python :smile_cat: