【DALI笔记】Python调用C++扩展库联合调试的学习笔记

我们目前计划了三种调试方式:

  • VisualStudio: VisualStudio可以支持WSL2系统;
  • VSCode联合调试:使用插件 Python C++ Debugger
  • TotalView:TotalView支持Python&C++联合调试;

关于VSCode使用GDB进行联合调试的方法,请参考知乎文章《编译、调试PyTorch源码》

1. VisualStudio联合调试

2. VSCode联合调试

关于在VSCode中调试python-C++代码,请参考《vscode python/C++ Debug 调试 Pytorch源码》
Python C++ Debugger主要支持对调用C++共享链接库的python代码的调试;

Demo of launch.json on Ubuntu

{
  "version": "0.2.0",
  "configurations": [
    {
      "name": "Python C++ Debug",
      "type": "pythoncpp",
      "request": "launch",
      "pythonLaunchName": "Python: Current File",
      "cppAttachName": "(gdb) Attach",
    },
    {
      "name": "(gdb) Attach",
      "type": "cppdbg",
      "request": "attach",
      "processId": ""
    },
    {
      "name": "Python: Current File",
      "type": "python",
      "request": "launch",
      "program": "${file}",
      "console": "integratedTerminal"
    }
  ]
}

你可能感兴趣的:(python,c++,学习)