编译aarch64的gdb
下载gdb源代码:
编译gdb(在x86上运行)
../configure --prefix=/maxvision/opt/gdb --host=x86_64-linux-gnu --target=arm-linux-gnueabi --disable-nls --without-doc
编译gdbserver(在目标机器下运行,编译的是静态链接版本)
../gdb/gdbserver/configure --prefix=/maxvision/opt/gdb-server/aarch64 --host=aarch64-linux-gnu --target=aarch64-linux-gnu LDFLAGS="-static"
../gdb/gdbserver/configure --prefix=/maxvision/opt/gdb-server/aarch64 --host=arm-linux-gnueabi --target=arm-linux-gnueabi LDFLAGS="-static"
编译完了开始使用
名称说明:
目标机器:最终程序运行的设备。
开发机器:编写代码,交叉编译机器。VSCODE运行的机器
目标机器运行
aarch64-linux-gnu-gdbserver 目标机IP:端口号 需要调试运行的程序
示例:aarch64-linux-gnu-gdbserver 172.31.50.110:60010 demo_test
配置开发机器(VSCODE):
{
// 使用 IntelliSense 了解相关属性。
// 悬停以查看现有属性的描述。
// 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "(gdb) Launch",
"type": "cppdbg",
"request": "launch",
"program": "程序在开发机器上的绝对路径包括文件名",
"cwd": "程序的工作目录",
"args": [],
"stopAtEntry": false,
"miDebuggerPath": "之前编译的gdb完整路径 /xxx/aarch64-linux-gnu-gdb",
"miDebuggerServerAddress": "目标机器IP:端口 172.31.50.110:60010",
"environment": [],
"externalConsole": true,
"MIMode": "gdb",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
]
}
]
}
其他:
开启coredump(仅在当前shell下有效)
ulimit -c unlimited
echo "/coredumpdir//core.%e.%p" | sudo tee /proc/sys/kernel/core_pattern