喵
gdb调试
记录使用vscode图形化调试嵌入式设备上c++程序的过程,例如orin.
由于嵌入式设备未直接接入网络,因此调试还经过了跳板机.
嵌入式设备
准备好包含debug信息的可执行程序,使用gdbserver开启调试.
cuda-gdbserver :1234 test 1 2 3
attach
attach需要额外配置打开权限
# 临时配置
sudo sh -c "echo 0 >/proc/sys/kernel/yama/ptrace_scope"
# 永久配置
sudo sh -c "echo "kernel.yama.ptrace_scope = 0" >> /etc/sysctl.conf"
client
ssh config
以下配置实现了以下效果:
ssh orin1__1可以跳过orin1,直接连接到orin,同时将client的1234端口映射为orin的1234端口 ```sh ServerAliveInterval 20 TCPKeepAlive no StrictHostKeyChecking no NoHostAuthenticationForLocalhost yes RequestTTY yes Host *__1 HostName 172.16.45.98 LocalForward 1234 172.16.45.98:1234 Host *__2 HostName 172.16.45.100 Host *__1 *__2 User nvidia Port 22 UserKnownHostsFile /dev/null LogLevel ERROR
Host orin* User mi Port 1997
Host orin1 HostName 10.235.234.30 LocalForward 1234 172.16.45.98:1234
Host orin1_* ProxyJump orin1
### launch.json
```json
{
"version": "0.2.0",
"configurations": [
{
"type": "cppdbg",
"request": "launch",
"name": "remote debug",
"program": "${workspaceFolder}/build/test",
"cwd": "${workspaceFolder}",
"miDebuggerPath": "/usr/bin/gdb-multiarch",
"miDebuggerServerAddress": "127.0.0.1:1234",
"stopAtEntry": true,
"sourceFileMap": {
// "/proc/self/cwd": "/home/ycc/code/mipilot/develop"
}
}
]
}
启动
按下f5即可