[MySQL 调试] 初试breakpad

breakpad是google开源的一个崩溃报告工具,按照其声称,生成的core file相当小,近日开始调研将其集成到我们线上MySQL的可行性,以下是初步的安装尝试

1. checkout 代码

svn co http://google-breakpad.googlecode.com/svn/trunk  breakpad

2. configure && make && make install

3.暴力cp src/client/linux/libbreakpad_client.a

4.测试程序

#include “client/linux/handler/exception_handler.h”
#include <cstdio>

static bool dumpCallback(const google_breakpad::MinidumpDescriptor &md,
void* context,
bool succeeded)
{
printf(“Dump path: %s\n”, md.path());
return succeeded;
}

void crash()
{
volatile int* a = (int*)(NULL);
*a = 1;
}

int main()
{
google_breakpad::MinidumpDescriptor md(“/tmp”);
google_breakpad::ExceptionHandler eh(md, NULL, dumpCallback, NULL, true, -1);
crash();
return 0;
}

 

g++ test.cc -o test -g  -I src/  -lbreakpad_client  -lpthread

$./test
Dump path: /tmp/19b5df9c-6935-3923-125a8f20-21844c05.dmp
Segmentation fault

 

breakpad包含了几个工具:

a.dump_syms用于产生程序的符号信息

dump_syms ./tesr  > test.sym

$dump_syms ./test  > test.sym
$head -n1 test.sym
MODULE Linux x86_64 CE30BAB82B8B4B73D3A169C97011971D0 test

 

mkdir -p ./symbols/test/CE30BAB82B8B4B73D3A169C97011971D0

mv test.sym ./symbols/test/CE30BAB82B8B4B73D3A169C97011971D0/

 

b.minidump_stackwalk  用于分析产生的dmp文件,输出堆栈,CPU,OS等信息

例如

$minidump_stackwalk  /tmp/19b5df9c-6935-3923-125a8f20-21844c05.dmp  ./symbols
2012-09-16 02:48:06: minidump_processor.cc:264: INFO: Processing minidump in file /tmp/19b5df9c-6935-3923-125a8f20-21844c05.dmp
2012-09-16 02:48:06: minidump.cc:3780: INFO: Minidump opened minidump /tmp/19b5df9c-6935-3923-125a8f20-21844c05.dmp
2012-09-16 02:48:06: minidump.cc:3825: INFO: Minidump not byte-swapping minidump
2012-09-16 02:48:06: minidump.cc:4191: INFO: GetStream: type 1197932545 not present
2012-09-16 02:48:06: minidump.cc:4191: INFO: GetStream: type 1197932546 not present
2012-09-16 02:48:06: minidump.cc:1959: INFO: MinidumpModule could not determine version for /u01/project/breakpad/test
2012-09-16 02:48:06: minidump.cc:1959: INFO: MinidumpModule could not determine version for /lib64/ld-2.12.so
2012-09-16 02:48:06: minidump.cc:1959: INFO: MinidumpModule could not determine version for /lib64/libc-2.12.so
2012-09-16 02:48:06: minidump.cc:1959: INFO: MinidumpModule could not determine version for /lib64/libpthread-2.12.so
2012-09-16 02:48:06: minidump.cc:1959: INFO: MinidumpModule could not determine version for /lib64/libm-2.12.so
2012-09-16 02:48:06: minidump.cc:1959: INFO: MinidumpModule could not determine version for /lib64/libgcc_s-4.4.5-20110214.so.1
2012-09-16 02:48:06: minidump.cc:1959: INFO: MinidumpModule could not determine version for /usr/lib64/libstdc++.so.6.0.13
2012-09-16 02:48:06: minidump.cc:1959: INFO: MinidumpModule could not determine version for linux-gate.so
2012-09-16 02:48:06: minidump_processor.cc:116: INFO: Minidump /tmp/19b5df9c-6935-3923-125a8f20-21844c05.dmp has CPU info, OS info, no Breakpad info, exception, module list, thread list, no dump thread, and requesting thread
2012-09-16 02:48:06: minidump_processor.cc:150: INFO: Looking at thread /tmp/19b5df9c-6935-3923-125a8f20-21844c05.dmp:0/1 id 0x2fbb
2012-09-16 02:48:06: minidump.cc:308: INFO: MinidumpContext: looks like AMD64 context
2012-09-16 02:48:06: minidump.cc:308: INFO: MinidumpContext: looks like AMD64 context
2012-09-16 02:48:06: source_line_resolver_base.cc:220: INFO: Loading symbols for module /u01/project/breakpad/test from memory buffer
2012-09-16 02:48:06: simple_symbol_supplier.cc:193: INFO: No symbol file at ./symbols/libc-2.12.so/3D56C84D4CA1C801848D81D06507EDFF0/libc-2.12.so.sym
2012-09-16 02:48:06: simple_symbol_supplier.cc:131: INFO: Cannot find symbol data buffer for module /lib64/libc-2.12.so
2012-09-16 02:48:06: basic_code_modules.cc:88: INFO: No module at 0x0
2012-09-16 02:48:06: basic_code_modules.cc:88: INFO: No module at 0x7fffbf45a5d8
2012-09-16 02:48:06: basic_code_modules.cc:88: INFO: No module at 0x100000000
2012-09-16 02:48:06: minidump_processor.cc:258: INFO: Processed /tmp/19b5df9c-6935-3923-125a8f20-21844c05.dmp
2012-09-16 02:48:06: minidump.cc:3752: INFO: Minidump closing minidump
Operating system: Linux
0.0.0 Linux 2.6.32-220.17.1.tb619.el6.x86_64 #1 SMP Fri Jun 8 13:48:13 CST 2012 x86_64
CPU: amd64
family 0 model 0 stepping 0
1 CPU

Crash reason:  SIGSEGV
Crash address: 0x0

Thread 0 (crashed)
0  test!crash [test.cc : 15 + 0x4]
rbx = 0x00007fffbf45a4b0   r12 = 0x00000000004015e0
r13 = 0x00007fffbf45a5d0   r14 = 0x0000000000000000
r15 = 0x0000000000000000   rip = 0x000000000040170d
rsp = 0x00007fffbf45a430   rbp = 0x00007fffbf45a430
Found by: given as instruction pointer in context
1  test!main [test.cc : 22 + 0x4]
rbx = 0x00007fffbf45a4b0   r12 = 0x00000000004015e0
r13 = 0x00007fffbf45a5d0   r14 = 0x0000000000000000
r15 = 0x0000000000000000   rip = 0x00000000004017fc
rsp = 0x00007fffbf45a440   rbp = 0x00007fffbf45a4f0
Found by: call frame info
2  libc-2.12.so + 0x1ec9c
rbx = 0x0000000000000000   r12 = 0x00000000004015e0
r13 = 0x00007fffbf45a5d0   r14 = 0x0000000000000000
r15 = 0x0000000000000000   rip = 0x000000388881ec9d
rsp = 0x00007fffbf45a500   rbp = 0x0000000000000000
Found by: call frame info
3  test!crash [test.cc : 16 + 0x1]
rip = 0x0000000000401715   rsp = 0x00007fffbf45a520
Found by: stack scanning

Loaded modules:
0x00400000 – 0x00410fff  test  ???  (main)
0x3888000000 – 0x388801ffff  ld-2.12.so  ???
0x3888800000 – 0x3888b8bfff  libc-2.12.so  ???
0x3888c00000 – 0x3888e18fff  libpthread-2.12.so  ???
0x3889400000 – 0x3889683fff  libm-2.12.so  ???
0x388b400000 – 0x388b615fff  libgcc_s-4.4.5-20110214.so.1  ???
0x388e400000 – 0x388e6f0fff  libstdc++.so.6.0.13  ???
0x7fffbf5ff000 – 0x7fffbf5fffff  linux-gate.so  ???

简单记录下,还在摸索阶段,下一步尝试将其合并到MySQL中,看看生成的core file大小是否可以接受。

原创文章,转载请注明: 转载自Simple Life

本文链接地址: [MySQL 调试] 初试breakpad

Post Footer automatically generated by wp-posturl plugin for wordpress.


Comments

Leave a Reply

Your email address will not be published. Name and email are required


Current month ye@r day *