CentOS gdb core 调试错误: error reading variable: can't compute CFA for this frame

1、./test 程序运行错误
Segmentation fault (core dumped)

通常都是指针错误引起的。但这不像编译错误一样会提示文件一行,而是没有任何信息。一种办法是用gdb的step,一步一步寻找。但要step一个上万行的代码让人难以想象。 我们还有更好的办法,这就是core file。

2、gdb core 调试

如果想让系统在信号中断造成的错误时产生core文件,我们需要在shell中按如下设置:
设置core大小为无限      ulimit -c unlimited
设置文件大小为无限       ulimit unlimited

发生core dump之后,用gdb进行查看core文件内容,以定位文件中引发core dump的行:
gdb [exec file] [core file]

如: gdb ./test test.core 在进入gdb后, 用bt命令查看backtrace以检查发生程序运行到哪里,来定位core dump的文件->行。
另外需要注意的是,如果你的机器上跑很多的应用,你生成的core又不知道是哪个应用产生的,你可以通过下列命令进行查看:file core

3、gdb ./test core.1111 显示错误

./test=  error reading variable: can't compute CFA for this frame

4、原因查找

Bug 16215 - SPARC: can't compute CFA for this frame 
https://sourceware.org/bugzilla/show_bug.cgi?id=16215

January 15th,2015: GDB 7.8.2 Released!

*The latest version of GDB,version 7.8.2,is available for download.
This is a minor corrective release over GDB 7.8.1,fixing the following issues:
PR symtab/17642 ([7.8 regression] internal-error: resolve_dynamic_struct: Assertion `TYPE_NFIELDS (type) > 0' Failed.)
PR binutils/17677 (_bfd_elf_get_synthetic_symtab runs in O(n^2) complexity)
PR gdb/16215 (SPARC: can't compute CFA for this frame)
PR gdb/17525 (target-async: breakpoint commands not executed when program run from -x script)
PR cli/17828 ([7.8 regression] -batch -ex r breaks terminal)* 
from:https://www.gnu.org/software/gdb/news/

5、解决方法
将gdb更新到7.8.2版本以上

当前版本:
$ gdb --version
GNU gdb (GDB) 7.7
更新版本:
wget http://ftp.gnu.org/gnu/gdb/gdb-7.12.tar.gz
tar zxvf gdb-7.12.tar.gz
cd gdb-7.12
./configure
make
sudo make install

相关文章

Centos下搭建性能监控Spotlight
CentOS 6.3下Strongswan搭建IPSec VPN
在CentOS6.5上安装Skype与QQ
阿里云基于centos6.5主机VPN配置
CentOS 6.3下配置multipah
CentOS安装、配置APR和tomcat-native