嵌入式开发板子(aarch64)程序编译(在ubuntu远程调试)
1.支持coredump, 并且设置coredump路径等
//生成文件路径与格式
echo '/data/coredump/%e-%t-%p-%c.core' > /proc/sys/kernel/core_pattern
// 设置开启coredump 并设置显示文件大小
void set_coreDumpAvalib(const rlim_t& coreFileSize)
{
printf("------------------>set_coreDumpAvalib : %d\n",(int)coreFileSize);
struct rlimit limit;
//limit.rlim_cur =RLIM_INFINITY; // 无限制大小
//limit.rlim_max =RLIM_INFINITY; // 无限制大小
limit.rlim_cur =coreFileSize; // 指定大小
limit.rlim_max =coreFileSize; // 指定大小
if(setrlimit(RLIMIT_CORE,&limit)!=0){
perror("setrlimit");
}
}
指令开启 ulimit -c unlimited
不管是使用指令开启还是代码开启,都只支持当前进程,不会板子其他进程生效
2.交叉编译gdb 与gdbserver
gdbserver 在板子上运行
gdb 在ubuntu 上运行
(交叉编译步骤不在此文章过多介绍)
将要调试的程序使用sshfs 挂载在ubuntu 某个目录。
在板子开启gdbserver
gdbserver 162.168.8.223:1234 test
在ubuntu 上tmpa 目录为挂载路径
aarch64-linux-gnu-gdb test test.core
进入gdb 后 执行 target remote 162.168.8.223:1234 即可。剩下的就是gdb 调试