google breakpad备忘录

编译

1
2
3
4
5
6
7
git clone https://github.com/google/breakpad.git
or
git clone https://chromium.googlesource.com/breakpad/breakpad

cd breakpad

git clone https://chromium.googlesource.com/linux-syscall-support src/third_party/lss

在代码中添加exception handler

1
2
3
4
5
6
#include "client/linux/handler/exception_handler.h"

void exception_handler_init(const char * path) {
    google_breakpad::MinidumpDescriptor descriptor(path); // minidump文件写入到的目录
    static google_breakpad::ExceptionHandler eh(descriptor, NULL, NULL, NULL, true, -1);
}

dump信息及解析

生成symbol信息

1
dump_syms ${path}/xxx.so > xxx.so.sym

根据head -n 1 xxx.so.sym所得到的信息

1
MODULE Linux x86_64 0B659766105832C2D9A83B22CBDD43480 xxx.so

来创建目录并把symbol文件放到对应目录下

1
2
mkdir -p symbols/xxx.so/0B659766105832C2D9A83B22CBDD43480
mv xxx.so.sym symbols/xxx.so/0B659766105832C2D9A83B22CBDD43480/

解析

1
minidump_stackwalk 4b5fc485-1c23-4bef-1700b383-3d47f73c.dmp ./symbols

参考资料