Visual Studio Code作为一款代码开发神器,有很多的插件来服务于代码的开发。
本文介绍如何通过vscode调试服务器上的tvm工程,因该工程位于服务器上因此需要先安装Remote SSH插件,该框架中包含C、C++、Python、GO等编程语言编写的代码,因此我们需要安装对应语言编译所需要的插件。
在tvm框架中C与C++程序属于后端接口,会根据要求编译成库文件,封装成python可调用的形式供前端调用。如果我们只是用gdb调试就无法完成前端调用后端的在线debug。
下面提供一种python与C混合调试的方法:
在软件上点击[Run and Debug] 选择 config from json, 会弹出launch.json的编辑框,将下面内容复制到该文件中,将./path/to/python/run.py替换为要运行的脚本即可在线调试
{
// 使用 IntelliSense 了解相关属性。
// 悬停以查看现有属性的描述。
// 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Python: launch",
"type": "python",
"request": "launch",
"python": "/usr/bin/python",
"program": "./path/to/python/run.py",
"console": "integratedTerminal",
"cwd": "${workspaceFolder}",
"stopOnEntry": true,
"justMyCode": false,
"outputCapture": "std"
},
{
"name": "GDB Launch",
"type": "cppdbg",
"request": "launch",
"program": "/usr/bin/python",
"args": [
"./path/to/python/run.py"
],
"MIMode": "gdb",
"cwd": "${workspaceFolder}",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
],
}
]
}
保存好后,再次点击[Run and Debug] 将会看到
以及[Python: launch]供选择,调试C代码选择[GDB Launch],调试python脚本选择[Python: launch]就可以在线Debug了。