1. breakpad简介
BreakPad
是Google开发的一款软件崩溃信息记录工具,其大致原理是捕获系统底层发出的崩溃信号,将此刻软件的堆栈信息并进行分析生成报告,可以很方便的定位问题代码。
2. 安装
下载Breakpad,终端输入 git clone https://github.com/google/breakpad
下载载Breakpad依赖的库,git clone https://github.com/adelshokhy112/linux-syscall-support
将linux-syscall-support/lss
文件夹拷贝到breakpad/src/third_party
目录下
编译 ./configure && make
编译完成后,
libbreakpad_client.a
在breakpad/src/client/linux/
下
dump_syms
在breakpad/src/tools/linux/dump_syms/
下
minidump_stackwalk
在breakpad/src/processor
下
3. 示例
下边是一个Google官方给出的例子:
#include "client/linux/handler/exception_handler.h"
static bool dumpCallback(const google_breakpad::MinidumpDescriptor& descriptor,
void* context, bool succeeded) {
printf("Dump path: %s\n", descriptor.path());
return succeeded;
}
void crash() {
volatile int* a = (int*)(NULL); *a = 1; } //core dumped
int main() {
google_breakpad::MinidumpDescriptor descriptor("./");
google_breakpad