zoukankan      html  css  js  c++  java
  • linux下core dump文件分析

    #include <stdio.h>
    #include <string.h>
    
    int main()
    {
       char *str = "hello";
    
       strcpy(str, "furong");
    
       return 0;
    }
    

    产生core文件

    gcc dump.c -g
    

    开启core dump功能

    ulimit -c unlimited
    

    查看core文件

    zxc@ubuntu:~/test$ gdb a.out 
    GNU gdb (Ubuntu 7.11.1-0ubuntu1~16.5) 7.11.1
    Copyright (C) 2016 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 "x86_64-linux-gnu".
    Type "show configuration" for configuration details.
    For bug reporting instructions, please see:
    <http://www.gnu.org/software/gdb/bugs/>.
    Find the GDB manual and other documentation resources online at:
    <http://www.gnu.org/software/gdb/documentation/>.
    For help, type "help".
    Type "apropos word" to search for commands related to "word"...
    Reading symbols from a.out...done.
    (gdb) core-file core 
    [New LWP 8716]
    Core was generated by `./a.out'.
    Program terminated with signal SIGSEGV, Segmentation fault.
    #0  0x00000000004004e6 in main () at dump.c:8
    8          strcpy(str, "furong");
    (gdb) q
    

    addr2line

    zxc@ubuntu:~/test$ addr2line -e a.out 0x00000000004004e6 -f
    main
    /home/zxc/test/dump.c:8
    
  • 相关阅读:
    冒泡排序
    线程同步
    线程取消
    线程分离
    第3月第2天 find symbolicatecrash 生产者-消费者 ice 引用计数
    第3月第1天 GCDAsyncSocket dispatch_source_set_event_handler runloop
    第2月第25天 BlocksKit
    第2月第24天 coretext 行高
    第2月第6天 iOS 运行时添加属性和方法
    第2月第5天 arc invocation getReturnValue
  • 原文地址:https://www.cnblogs.com/zhangxuechao/p/15557926.html
Copyright © 2011-2022 走看看