jjzhang166 / coredump

to show how to make coredump and how to analyze it

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

coredump的路径和格式:
  修改配置文件/etc/sysctl.conf(重启后生效)
  kernel.core_pattern = core
  kernel.core_uses_pid = 1

    将COREDUMP的SIZE设置成无限大
  ulimit -S -c unlimited
    ulimit -c 1024 (1024 bytes size of coredump file)
  
  查看系统限制
  ulimit -a

    存放路径: 当前目录
    

Compile the code:
    gcc -o test -g test.c

gdb
    gdb test core.3628
    在进入gdb后, 用bt命令查看backtrace以检查发生程序运行到哪里, 来定位core dump的文件行

    tomxue@ubuntu:~/mycode/0___GitHub/coredump$ gdb test core.3628 
    GNU gdb (Ubuntu/Linaro 7.4-2012.04-0ubuntu2.1) 7.4-2012.04
    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-linux-gnu".
    For bug reporting instructions, please see:
    <http://bugs.launchpad.net/gdb-linaro/>...
    Reading symbols from /home/tomxue/mycode/0___GitHub/coredump/test...done.
    [New LWP 3628]
    Core was generated by `./test'.
    Program terminated with signal 11, Segmentation fault.
    #0  0x080483f4 in a () at test.c:6
    6          printf("%d/n", *p);
    (gdb) bt
    #0  0x080483f4 in a () at test.c:6
    #1  0x08048418 in main () at test.c:11
    (gdb) 


    if no coredump provided...

    tomxue@ubuntu:~/mycode/0___GitHub/coredump$ gdb test
    GNU gdb (Ubuntu/Linaro 7.4-2012.04-0ubuntu2.1) 7.4-2012.04
    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-linux-gnu".
    For bug reporting instructions, please see:
    <http://bugs.launchpad.net/gdb-linaro/>...
    Reading symbols from /home/tomxue/mycode/0___GitHub/coredump/test...done.
    (gdb) bt
    No stack.
    (gdb) 

About

to show how to make coredump and how to analyze it