x86 本地调试:.vscode 目录下 launch.json 文件内容模板,

{
"version": "0.2.0",
"configurations": [
{
"name": "Debug",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/build_x86/HelloWorld", //program 调试哪个程序:路径
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": false,
"MIMode": "gdb",
"miDebuggerPath": "/usr/bin/gdb", //GDB调试器 路径
"setupCommands": [
{
"description": "为 gdb 启用整齐打印",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
]
}
]
}
虚拟机 + ARM 交叉编译 + GDB 远程调试:.vscode 目录下 launch.json 文件内容模板:

{
"version": "0.2.0",
"configurations": [
{
"name": "Debug ARM Remote",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/gdbtest", //ARM 可执行文件路径
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": false,
"MIMode": "gdb",
"miDebuggerPath": "/usr/local/arm/gcc-linaro-4.9.4-2017.01-x86_64_arm-linux-gnueabihf/bin/arm-linux-gnueabihf-gdb", // ARM 版本 GDB
"miDebuggerServerAddress": "192.168.137.50:2001", // 远程服务器地址,开发板ip
"setupCommands": [
{
"description": "为 gdb 启用整齐打印",
"text": "-enable-pretty-printing",
"ignoreFailures": true
},
]
}
]
}
**远程调试:**启动开发板上的 gdbserver,输入命令: gdbserver 192.168.137.50:2001 gdbtest
点击 VSCode 上的"调试" ->"启动调试"按钮,等待连接成功。