1. 确认是否开启生成core
ulimit -c
若为unlimited或是具体数字, 则是打开的
若为0, 则说明生成core文件是关闭的, 开启命令为: ulimit -c unlimited 或 ulimit -c 33268
2. 获取core dump文件, 跳过systemd, 生成在指定目录,比如当前可执行文件所在目录
sysctl -w 'kernel.core_pattern=%t-%e-%p-%c.core', 当然,需要管理员权限才可以
3. bt命令查看
生成xxxxx.core文件后,运行
gdb exe_file_name xxxxx.core
进入(gdb)
输入bt查看core dump 所在位置
4. arm linux 调试事例:
gdb CT360 1568614925-RtPlotSurface-1256-4294967295.core
(gdb)bt
#0 0xb6e95eae in CPP1Name::FUNCTION1(this=0x3aa860, start_tick=8, duration_tick=248) at CPP1Name.cpp:191
#1 0xb6e921f4 in CPP2Name::FUNCTION2(this=0xb6f54150 <SIGTON::GetInstance()::instance>, pdata_dest=0x294ab4, read_samp_size=31, ptick_time=0xae8e4e00) at CPP2Name.cpp:59
#2 0xb6f134fe in CPP3Name::FUNCTION3(this=0x293ff0) at CPP3Name.cpp:277
#3 0xb6f13058 in CPP4Name::run (this=0x293ff0) at CPP3Name.cpp:161
#4 0xb612bc0e in ?? () from /opt/Qt-arm-5.6.3/lib/libQt5Core.so.5
#5 0xb6071494 in start_thread (arg=0xbf0f8ed2) at pthread_create.c:458
#6 0xb5dfa1ac in ?? () at ../sysdeps/unix/sysv/linux/arm/clone.S:76 from /lib/libc.so.6
Backtrace stopped: previous frame identical to this frame (corrupt stack?)