coredump及调试

作者: yanchenghust | 来源:发表于2019-07-06 19:03 被阅读0次

    什么是coredump?

    coredump是程序崩溃时的内存快照。
    操作系统在程序发生异常而异常在进程内部又没有被捕获的情况下,会把进程此刻内存、寄存器状态、运行堆栈等信息转储保存在一个文件里。

    什么场景/怎样才能出coredump?

    ulimit -c 可以设置core文件的大小,如果这个值为0.则不会产生core文件,这个值太小,则core文件也不会产生,因为core文件一般都比较大。

    查看ulimit

    ulimit -c
    

    设置ulimit

    ulimit -c unlimited
    ulimit -c 1024
    

    coredump存储目录在哪?

    • linux操作系统
      /proc/sys/kernel/core_pattern定义了下coredump路径的pattern。

    gdp调试coredump

    gdb sbin/nginx cores/core.nginx.1562145687.176208
    

    输出为:

    [Thread debugging using libthread_db enabled]
    Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
    Core was generated by `nginx: worker process                               '.
    Program terminated with signal SIGSEGV, Segmentation fault.
    #0  ngx_vslprintf (buf=0x7fffc9da3c68 "\320=\332\311\377\177",
        buf@entry=0x7fffc9da3c5a "my_test_conf: \320=\332\311\377\177", last=last@entry=0x7fffc9da4c30 "",
        fmt=0x742d76 "s", fmt@entry=0x742d67 "my_test_conf: %s", args=args@entry=0x7fffc9da3c18)
        at src/core/ngx_string.c:272
    272                     while (*p && buf < last) {
    

    相关文章

      网友评论

        本文标题:coredump及调试

        本文链接:https://www.haomeiwen.com/subject/lwuchctx.html