运行了一个程序,出现Segmentation fault,用gdb调试打印信息如下
(gdb) where
#0 _IO_vfprintf_internal (s=s@entry=0x0, format=format@entry=0xb77c171d "%d ", ap=ap@entry=0xbf8de928 "\232\003")
at vfprintf.c:1295
#1 0xb74fb26f in __fprintf (stream=0x0, format=0xb77c171d "%d ") at fprintf.c:32
#2 0xb77c0888 in onWrite (varKey=922) at MemTracer.cpp:130
#3 0x08048d54 in main () at test.cpp:90
(gdb) r
Starting program: /home/yancai/Research/llvm/MemTrace/test/test.out
Traceback (most recent call last):
File "/usr/share/gdb/auto-load/usr/lib/i386-linux-gnu/libstdc++.so.6.0.19-gdb.py", line 63, in <module>
from libstdcxx.v6.printers import register_libstdcxx_printers
ImportError: No module named 'libstdcxx'
/*libMemTrace loaded.*/
/*ConfigFile is: /home/yancai/Research/llvm/MemTrace//cfg.cfg*/
/*To trace ...*/
/*Failed to create file: /home/yancai/Research/llvm/MemTrace/traces/18361.trace.*/
Program received signal SIGSEGV, Segmentation fault.
_IO_vfprintf_internal (s=s@entry=0x0, format=format@entry=0xb7fd771d "%d ", ap=ap@entry=0xbfffed78 "\232\003") at vfprintf.c:1295
1295 vfprintf.c: No such file or directory.
我看了一下,出错的应该是我程序里这一句fprintf(outFile, "%d ", varKey);
//varKey is int
查了网上关于vprintf段错误,这里的问题并不是把%d写成%s,应该是s=s@entry=0x0,0x0是不是不能访问,但是我不知道怎么修改,求大神帮忙,谢谢!