程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> C語言 >> C++ >> C++入門知識 >> linux下發布的執行文件崩潰的問題定位 心得一則

linux下發布的執行文件崩潰的問題定位 心得一則

編輯:C++入門知識

C++ Release版本發布到客戶處執行時,如果程序崩潰,有什麼辦法能夠快速的確認程序的問題呢?

  • 如果能gdb調試的話,比較簡單了,可以使用gdb命令,類似如下:

gdb ##
set args ****
b main
r
#eip
x/10i 0xb7362040

 

  • 如果開發不在現場等情況,此時可以使用記錄崩潰日志的方法進行分析

此時首先要求的是項目使用類似google breakpad這個工具庫,對崩潰進行記錄

默認breakpad生成的是dmp文件,可以使用breakpad帶的工具轉換成文字進行查看,如下:

./minidump-2-core -m 7ee5c76f-afe2-f9bd-564dedb7-57d73e0c.dmp >core

./minidump_stackwalk 7ee5c76f-afe2-f9bd-564dedb7-57d73e0c.dmp > dbg.txt

此時根據如上的信息可以確定哪個模塊的地址出錯了

 

由於一般的情況,發布的庫的源代碼對應版本提取,編譯比較麻煩,可以直接拿對應出錯的庫或執行文件進行分析,使用objdump生成出匯編文件,通過對應地址可以初步找到哪個函數出問題,至於猜測出來的代碼,那需要根據分析情況構建單元測試或者重新上線進行檢驗

具體的一些過程實例如下:
objectdump -d ##.so > ##.o
vim ##.o
6 libTaps2.so + 0xa452d

./minidump_stackwalk 7ee5c76f-afe2-f9bd-564dedb7-57d73e0c.dmp

Thread 7 (crashed)
0 linux-gate.so + 0x430
eip = 0xb78b4430 esp = 0xb2952e18 ebp = 0xb2952e30 ebx = 0x00000fff
esi = 0xb5b98864 edi = 0xb5b97ff4 eax = 0x00000000 ecx = 0x00001008
edx = 0x00000006 efl = 0x00000206
Found by: given as instruction pointer in context
1 libc-2.11.1.so + 0x2da81
eip = 0xb5a6fa82 esp = 0xb2952e38 ebp = 0xb2952f58
Found by: previous frame's frame pointer
2 libstdc++.so.6.0.13 + 0xbf52e
eip = 0xb5cba52f esp = 0xb2952f60 ebp = 0xb2952fa8
Found by: previous frame's frame pointer
3 libstdc++.so.6.0.13 + 0xbd464
eip = 0xb5cb8465 esp = 0xb2952fb0 ebp = 0xb2952fc8
Found by: previous frame's frame pointer
4 libstdc++.so.6.0.13 + 0xbd4a1
eip = 0xb5cb84a2 esp = 0xb2952fd0 ebp = 0xb2952fe8
Found by: previous frame's frame pointer
5 libstdc++.so.6.0.13 + 0xbd5e0
eip = 0xb5cb85e1 esp = 0xb2952ff0 ebp = 0xb2953008
Found by: previous frame's frame pointer
6 libTaps2.so + 0xa452d
eip = 0xb738c52e esp = 0xb2953010 ebp = 0xb2953048
Found by: previous frame's frame pointer
7 libTaps2.so + 0x7a03f
eip = 0xb7362040 esp = 0xb2953050 ebp = 0xb2953068
Found by: previous frame's frame pointer
8 libTaps2.so + 0x6aa9d
eip = 0xb7352a9e esp = 0xb2953070 ebp = 0xb29530b8
Found by: previous frame's frame pointer
9 libTaps2.so + 0x68e69
eip = 0xb7350e6a esp = 0xb29530c0 ebp = 0xb2953108
Found by: previous frame's frame pointer
10 libTaps2.so + 0x691a2
eip = 0xb73511a3 esp = 0xb2953110 ebp = 0xb2953158
Found by: previous frame's frame pointer
11 libTaps2.so + 0x71b9c
eip = 0xb7359b9d esp = 0xb2953160 ebp = 0xb29531a8
Found by: previous frame's frame pointer
12 libTaps2.so + 0x71db1
eip = 0xb7359db2 esp = 0xb29531b0 ebp = 0xb29531b8
Found by: previous frame's frame pointer
13 libTaps2.so + 0xa8ac9
eip = 0xb7390aca esp = 0xb29531c0 ebp = 0xb2953208
Found by: previous frame's frame pointer
14 libTaps2.so + 0xa98d8
eip = 0xb73918d9 esp = 0xb2953210 ebp = 0xb2953288
Found by: previous frame's frame pointer
15 libTaps2.so + 0xa78b0
eip = 0xb738f8b1 esp = 0xb2953290 ebp = 0xb29532b8
Found by: previous frame's frame pointer
16 libTaps2.so + 0xa7960
eip = 0xb738f961 esp = 0xb29532c0 ebp = 0xb29532e8
Found by: previous frame's frame pointer
17 libTaps2.so + 0xa88a5
eip = 0xb73908a6 esp = 0xb29532f0 ebp = 0xb2953338
Found by: previous frame's frame pointer
18 libTaps2.so + 0x7207a
eip = 0xb735a07b esp = 0xb2953340 ebp = 0xb2953358
Found by: previous frame's frame pointer
19 tapsdaemon + 0x2e168
eip = 0x08076169 esp = 0xb2953360 ebp = 0xb2953388
Found by: previous frame's frame pointer
20 libpthread-2.11.1.so + 0x596d
eip = 0xb5ba196e esp = 0xb2953390 ebp = 0xb2953488
Found by: previous frame's frame pointer
21 libc-2.11.1.so + 0xcda4d
eip = 0xb5b0fa4e esp = 0xb2953490 ebp = 0x00000000
Found by: previous frame's frame pointer

 

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved