gdb coredump 分析堆棧

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

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章