1)对linux 环境做配置,当有异常生成coredump时候,指定coredump的命名格式和路径
ulimit -S -c unlimited >/dev/null 2>&1
echo '/tmp/core_%e.%p' > /proc/sys/kernel/core_pattern
ulimit -c unlimited
2)定位符号
(gdb) info register rbp
x/64xg %rbp // x86_64 环境
3) 定位行号
a)
(gdb) info symbol 0x00007f9fc4a8e0d2
switch_hash_insert + 74 in section .text of switch.so
b)
objdump -t switch.so | grep "switch_hash_insert"
00000000000f2088 g F .text 0000000000000059 switch_hash_insert
c)
0x00000000000f2088 + 0x4a (i.e. 74) = 0xf20d2
d)
addr2line -e switch.so 0xf20d2
switch_hash.c:62