core dump
来源:互联网 发布:oracle找回删除数据 编辑:程序博客网 时间:2024/05/07 11:01
详细内容见man文档:
man 5 core。http://man7.org/linux/man-pages/man5/core.5.html
man ulimit
把上面的man文档看一遍就差不多了。
我遇到的问题是,没能成功生成coredump文件。
解决办法:使用ulimit 改变core文件大小限制。
$ ulimit -S -acore file size (blocks, -c) 0data seg size (kbytes, -d) unlimitedscheduling priority (-e) 0file size (blocks, -f) unlimitedpending signals (-i) 24110max locked memory (kbytes, -l) 64max memory size (kbytes, -m) unlimitedopen files (-n) 1024pipe size (512 bytes, -p) 8POSIX message queues (bytes, -q) 819200real-time priority (-r) 0stack size (kbytes, -s) 8192cpu time (seconds, -t) unlimitedmax user processes (-u) 1024virtual memory (kbytes, -v) unlimitedfile locks (-x) unlimited
上面显示core file size 为0个block。把它改大点就能生成coredump文件了。
$ ulimit -S -acore file size (blocks, -c) unlimiteddata seg size (kbytes, -d) unlimitedscheduling priority (-e) 0file size (blocks, -f) unlimitedpending signals (-i) 24110max locked memory (kbytes, -l) 64max memory size (kbytes, -m) unlimitedopen files (-n) 1024pipe size (512 bytes, -p) 8POSIX message queues (bytes, -q) 819200real-time priority (-r) 0stack size (kbytes, -s) 8192cpu time (seconds, -t) unlimitedmax user processes (-u) 1024virtual memory (kbytes, -v) unlimitedfile locks (-x) unlimited
这样问题就解决了。
注意这样只对当前终端有效。
设置好core 文件大小之后,可以调试一个core dump文件练练手。可以使用gdb 进行调试。
例子:
代码
main.c
int main(){char *p = "helloworld";p[0] = 'h';return 0;}
gcc -Wall -g main.c -o main
./main
会产生coredump文件,core.8151
gdb main core.8151 注意用gdb调试要带上原来的可执行文件,后面加上coredump文件。
$ gdb main core.8151 GNU gdb (GDB) Fedora (7.4.50.20120120-50.fc17)Copyright (C) 2012 Free Software Foundation, Inc.License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>This is free software: you are free to change and redistribute it.There is NO WARRANTY, to the extent permitted by law. Type "show copying"and "show warranty" for details.This GDB was configured as "i686-redhat-linux-gnu".For bug reporting instructions, please see:<http://www.gnu.org/software/gdb/bugs/>...Reading symbols from /home/huntinux/work/linker_loader/coredump/main...done.[New LWP 8151]Core was generated by `./main'.Program terminated with signal 11, Segmentation fault.#0 0x080483e0 in main () at main.c:44p[0] = 'h';Missing separate debuginfos, use: debuginfo-install glibc-2.15-57.fc17.i686(gdb) l1int main()2{3char *p = "helloworld";4p[0] = 'h';56return 0;7}(gdb) b 4Breakpoint 1 at 0x80483dd: file main.c, line 4.(gdb) rStarting program: /home/huntinux/work/linker_loader/coredump/main Breakpoint 1, main () at main.c:44p[0] = 'h';(gdb) sProgram received signal SIGSEGV, Segmentation fault.0x080483e0 in main () at main.c:44p[0] = 'h';
参考: http://prefetch.net/blog/index.php/2012/01/19/using-the-automated-bug-reporting-tool-abrt-to-generate-core-dumps-when-a-linux-process-fails/
http://man7.org/linux/man-pages/man5/core.5.html
- Core Dump
- Core Dump
- Core Dump?!
- Core Dump?!
- Core Dump?!
- core dump
- core dump
- Core Dump
- core dump
- Core dump
- core dump
- Core Dump
- core dump
- core dump
- Core Dump
- core dump
- Core Dump
- core dump
- Linux调教日记
- LabVIEW快捷键列表
- memcache学习笔记
- ongl 公共静态方法
- android中打开固定的网页
- core dump
- 第九章 作业
- oracle创建和删除表空间
- 邻接表--建图、spfa、EK算法 (转化为最小费用最大流)
- vbox centos 与开发板nfs配置
- STL中list学习
- 传入动态数组
- VC助手使用技巧
- (转载) 驻足 思考 -- 提升 思维方式