Coredump

Linux内核源码 Documentation/sysctl/kernel.txt core_pattern:

core_pattern:

core_pattern is used to specify a core dumpfile pattern name.
. max length 128 characters; default value is "core"
. core_pattern is used as a pattern template for the output filename;
  certain string patterns (beginning with '%') are substituted with
  their actual values.
. backward compatibility with core_uses_pid:
        If core_pattern does not include "%p" (default does not)
        and core_uses_pid is set, then .PID will be appended to
        the filename.
. corename format specifiers:
        %<NUL>  '%' is dropped
        %%      output one '%'
        %p      pid
        %P      global pid (init PID namespace)
        %i      tid
        %I      global tid (init PID namespace)
        %u      uid
        %g      gid
        %d      dump mode, matches PR_SET_DUMPABLE and
                /proc/sys/fs/suid_dumpable
        %s      signal number
        %t      UNIX time of dump
        %h      hostname
        %e      executable filename (may be shortened)
        %E      executable path
        %<OTHER> both are dropped
. If the first character of the pattern is a '|', the kernel will treat
  the rest of the pattern as a command to run.  The core dump will be
  written to the standard input of that program instead of to a file.

脚本

#!bin/bash

#/proc/<pid>/maps
cat /proc/$1/maps > /tmp/maps_of_$1

#/proc/<pid>/smaps
cat /proc/$1/smaps > /tmp/smaps_of_$1

#coredump
dd > /tmp/core_$1_$2_$3

#gzip

gzip > /tmp/core_$1_$2_$3

 

 

ulimit -c unlimited

echo "|/usr/local/coredump.sh %p %e %s" > /proc/sys/kernel/core_pattern

 

参考资料:

https://www.cnblogs.com/justin-y-lin/p/11327224.html

https://www.cnblogs.com/arnoldlu/p/11160510.html

http://www.brendangregg.com/blog/2016-08-09/gdb-example-ncurses.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值