Android使用google breakpad之minidump_stackwalk

Minidump总结

记录一下如何使用minidump解析crash.dmp文件
1. Build symbols (symbols will put into "objdir-gecko/dist/crashreporter-symbols/"):
在项目根目录下执行:

$ . setup.sh && make buildsymbols

2.获取minidump的原始文件:/data/b2g/mozilla/CrashReports/pending/

(dumpfile (xxx.dmp) and extra file will save under “/data/b2g/mozilla/Crash
Reports/pending/” if you didn't send them to server)

3.使用(minidump_stackwalk)解析转储原始文件为可读的dump_result.txt

有两种方式获取minidump_stackwalk工具:
3.1
方法一:
minidump_stackwalk 下载路径:http://hg.mozilla.org/build/tools/file/tip/breakpad/
3.2
方法二:
使用Google Breakpad
eg:
3.2.1:
下载Google Breakpad源码
git clone https://github.com/google/breakpad

3.2.2:
git clone https://chromium.googlesource.com/linux-syscall-support

(代码中很多地方引用了#include "third_party/lss/linux_syscall_support.h"这个Linux调用库,但源码中并没有给出lss目录,所以我们需要自己去下载https://chromium.googlesource.com/linux-syscall-support/源码,并将lss目录拷贝到third_party下,否则编译不过。)
3.2.3:
在源码目录下执行:
./configure && make
make install
--------------
这样在你编译Breakpad成功后,就可以使用Breakpad下的minidump_stackwalker 工具来根据 minidump 文件生成堆栈跟踪log

eg: /local/pier2_kk_3G/KaiOS$ minidump_stackwalk 4.dmp >dump_result.txt
或者: minidump_stackwalk dumpfile(xxx.dump) objdir-gecko/dist/crashreporter-symbols/ > dump_result.txt
成功的dump_result.txt
大致内容如下:


Operating system: Android
                  0.0.0 Linux 4.4.83 #1 SMP PREEMPT Tue Sep 24 11:28:43 CST 2019 armv7l
CPU: arm
     ARMv1 ARM part(0x4100d030) features: half,thumb,fastmult,vfpv2,edsp,neon,vfpv3,tls,vfpv4,idiva,idivt
     2 CPUs

GPU: UNKNOWN

Crash reason:  SIGSEGV /0x00000000
Crash address: 0x0
Process uptime: not available

Thread 14 (crashed)
 0  libmozglue.so + 0x2c82e
     r0 = 0x000000e5    r1 = 0xb05ff08c    r2 = 0x00000021    r3 = 0x00000000
     r4 = 0xb05ff544    r5 = 0x00000003    r6 = 0xb6e7d1f8    r7 = 0xb6e7d150
     r8 = 0xb4b86b31    r9 = 0xb656cb58   r10 = 0x00000000   r12 = 0x00000003
     fp = 0xadc1d358    sp = 0xb05ff508    lr = 0xb6ebf82b    pc = 0xb6ebf82e
    Found by: given as instruction pointer in context
 1  libxul.so + 0x3fad65
     sp = 0xb05ff510    pc = 0xb4b86d67
    Found by: stack scanning
 2  libxul.so + 0x1d86ad0
     sp = 0xb05ff520    pc = 0xb6512ad2
    Found by: stack scanning

Thread 0
 0  libc.so + 0x21888
     r0 = 0xae2f1e10    r1 = 0x00000080    r2 = 0x00000000    r3 = 0x00000000
     r4 = 0xae2f1e10    r5 = 0xae2f1e04    r6 = 0x00000000    r7 = 0x000000f0
     r8 = 0xffffffff    r9 = 0xb6f02168   r10 = 0x00000001   r12 = 0x00000000
     fp = 0xb3829f78    sp = 0xbe97ca48    lr = 0xb6e42054    pc = 0xb6e54888
    Found by: given as instruction pointer in context
 1  libmozglue.so + 0x2a447
     sp = 0xbe97ca60    pc = 0xb6ebd449
    Found by: stack scanning
 2  libmozglue.so + 0x2a94f
     sp = 0xbe97ca68    pc = 0xb6ebd951
    Found by: stack scanning
 3  libnss3.so + 0x114761
     sp = 0xbe97ca88    pc = 0xb46eb763
    Found by: stack
    -------------------------------

3.2.4:
addr2line

然后就可以使用addr2line 进行符号解析.从而追溯到对应该的堆栈信息.
(符号解析,可以使用 ndk 中提供的addr2line来根据地址进行一个符号反解的过程)
eg:
arm-linux-androideabi-addr2line -f -C -e (对于的.so库文件)  (符号地址)

你可能感兴趣的:(Android底层)