使用vscode debug cpp/python混合编程的程序(从python调用的C++编译的dll)
1. 安装插件 Python C++ Debugger
https://marketplace.visualstudio.com/items?itemName=benjamin-simmonds.pythoncpp-debug
2. 在.vscode/launch.json中增加配置
拷贝自 https://marketplace.visualstudio.com/items?itemName=benjamin-simmonds.pythoncpp-debug
{
"name": "Python C++ Debug",
"type": "pythoncpp",
"request": "launch",
"pythonLaunchName": "Python: Current File",
"cppAttachName": "(Windows) Attach",
},
{
"name": "(Windows) Attach",
"type": "cppvsdbg",
"request": "attach",
"processId": ""
},
{
"name": "Python: Current File",
"type": "python",
"request": "launch",
"program": "${file}",
"console": "integratedTerminal"
}
3. 开始调试
大致原理
采用了attach process的方式,大致是根据dll的process id将debugger挂载上去。
具体可查看
https://marketplace.visualstudio.com/items?itemName=benjamin-simmonds.pythoncpp-debug