zoukankan      html  css  js  c++  java
  • ubuntu生成core转储文件

    1、ulimit -c 判断是否开启转储

    为0 则没有开启

    2、ulimit -c unlimited 设置转储core大小没有限制

    3、设置转储文件位置 echo "/var/core/%t-%e-%p-%c.core"  > /proc/sys/kernel/core_pattern

    4、测试程序cpu_test

    1 int main(int argc, char **argv) {
    2    
    3     unsigned char * c = 0x00;
    4     *c = 'c';
    5 
    6     return 0;
    7 }

    5、运行./cpu_test 发生段错误、生成了core文件

    1521694447-cpu_test-77274-18446744073709551615.core
    1521696041-cpu_test-18423-18446744073709551615.core
    1521696511-cpu_test-26547-18446744073709551615.core
    1521698483-cpu_test-43924-18446744073709551615.core

    6、gdb分析core文件 gdb ./cpu_test /var/core/1521698483-cpu_test-43924-18446744073709551615.core

    Reading symbols from ./cpu_test...done.
    [New LWP 18689]
    Core was generated by `./cpu_test'.
    Program terminated with signal SIGSEGV, Segmentation fault.
    #0 0x000000000040075d in main (argc=1, argv=0x7ffebf1ceb18)
    at /home/karllen/projects/cpu_test/main.cpp:4
    4 *c = 'c';
    (gdb)

  • 相关阅读:
    模拟测试48
    模拟测试47
    模拟测试46
    NOIP模拟测试29(A)
    NOIP模拟测试19
    NOIP模拟测试18(T3待更新)
    杂题
    noip模拟测试18 T2搜索
    noip模拟测试17 2019-08-11 考后反思
    noip模拟测试14 20190807 考试反思
  • 原文地址:https://www.cnblogs.com/Forever-Kenlen-Ja/p/8623549.html
Copyright © 2011-2022 走看看