通常Android NDK出現崩潰以後,咱們會使用addr2line工具來進行符號化。若是你使用了C++11的一些特性,那麼要注意了,有可能你將獲得錯誤的函數名。咱們公司是提供崩潰分析相關的服務的,採集用戶的崩潰日誌,上傳到後臺服務器後,會進行符號化操做。以前一直好好的,最近有用戶說符號化後的結果不正確,函數名和文件及行號不一致。git
這個問題其實蠻奇怪的,要說addr2line但是操做系統級別的工具,無數人使用,不可能出這種低級錯誤啊。不過爲了進一步驗證,準備在本身的PC上用addr2line重現一下,結果發現,沒有問題,符號化是正確的。又到服務器上測試,發現仍然不對。查看addr2line的版本,發現是不一樣的,以下所示。redis
[root@tdata ~]# addr2line --version GNU addr2line version 2.20.51.0.2-5.42.el6 20100205 Copyright 2009 Free Software Foundation, Inc. This program is free software; you may redistribute it under the terms of the GNU General Public License version 3 or (at your option) any later version. This program has absolutely no warranty.
xxx@xxx-desktop:~/Templates/Tyrion-debug-tusuo$ addr2line --version GNU addr2line (GNU Binutils for Ubuntu) 2.24 Copyright 2013 Free Software Foundation, Inc. This program is free software; you may redistribute it under the terms of the GNU General Public License version 3 or (at your option) any later version. This program has absolutely no warranty.
看來應該是這個問題了,同時操做系統也不一樣,本身的是Ubuntu,服務器是CentOS。你們都知道,CentOS上的軟件通常版本都比較老,並且repo源沒有最新版本的更新,須要本身添加源。bash
首先想是否是將本身PC上的addr2line放到服務器上,就能夠解決問題了,由於這個文件是C語言寫的二進制文件。結果出現了下面的錯誤:
服務器
[root@tdata ~]# ./addr2line -f -e libgame.so 0x33e17b ./addr2line: error while loading shared libraries: libbfd-2.24-system.so: cannot open shared object file: No such file or directory
查閱了addr2line的源碼能夠發現,它會引用#include "bfd.h",會依賴libbfdxxx.so。ide
接着只能從官方下載新版本,再從新編譯,進行addr2line的版本升級。官網地址爲函數
ftp://sourceware.org/pub/binutils/snapshots/binutils-2.24.90.tar.bz2,你也能夠從git上同步代碼下來從新編譯。工具
注意最好到目標機器上進行編譯。在升級了addr2line以後,一切正常了。測試