Android系统coredump

1.打开内核coredump功能

Android系统的linux内核有可能没有打开coredump功能,可以通过查看android系统是否存在/proc/sys/kernel/core_patten配置项来确定,如果没有该配置项,那么需要重新配置内核,并且重新编译,并将其替换掉目标android系统内核(具体更新方试需要根据不同的硬件而定)。下面为coredump内核配置项的具体位置:

make menuconfig 
 Userspace binary formats-->
   [*] Enable core dump support

开启该选项,系统就支持程序的coredump功能,保存退出,重新编译内核,并下载到目标系统中就可了。重启后,在文件系统中应该就可看到/proc/sys/kernel/core_pattern配置项了。

2.配置coredump的存储位置

将core文件存储位置写入到/proc/sys/kernel/core_pattern即可,但/proc为内存文件系统,系统重启后,该配置会失效,所以对于android系统可以将配置该文件的命令写入到init.rc中,例如:


setrlimit 4  -1 -1      
                     
mkdir /data/coredump 0777 system system
             
write /proc/sys/kernel/core_pattern  /data/coredump/core.%e.%p

下面是关于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 
    %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
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值