首先,使用vscode
下载C/C++、remote SSH等插件
然后编写代码如图所示,
然后创建launch.jason如图所示:
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "(gdb) 启动",
"type": "cppdbg",
"request": "launch",
"program": "/${fileDirname}/${fileBasenameNoExtension}",
"args": [],
"stopAtEntry": false,
"cwd": "${fileDirname}",
"miDebuggerPath": "/home/myzr/my-work/toolchain/fsl-imx-xwaylan-x86_64-myimx6a7-4.9.88/sysroots/x86_64-pokysdk-linux/usr/bin/arm-poky-linux-gnueabi/arm-poky-linux-gnueabi-gdb",
"miDebuggerServerAddress": "192.168.173.81:7777",
"environment": [],
"externalConsole": false,
"MIMode": "gdb",
"setupCommands": [
{
"description": "为 gdb 启用整齐打印",
"text": "-enable-pretty-printing",
"ignoreFailures": true
},
{
"description": "将反汇编风格设置为 Intel",
"text": "-gdb-set disassembly-flavor intel",
"ignoreFailures": true
}
]
}
]
}
应该就可以远程调试linux了。
开发板打开ssh链接后,输入gdbserver 192.168.137.9:7777 ./test应该可以连上了