Andoid 利用ndk-stack定位崩潰代碼

Android NDK自從版本R6開始, 提供了一個工具ndk-stack( 在目錄{ndk_root}/中 ). 這個工具能自動分析dump下來的crash log, 將崩潰時的調用內存地址和c++代碼一行一行對應起來.html

執行命令ndk-stack --helpandroid

Usage: ndk-stack -sym <path> [-dump <path>] -sym Contains full path to the root directory for symbols. -dump Contains full path to the file containing the crash dump. This is an optional parameter. If ommited, ndk-stack will read input data from stdin
  • -dump參數很容易理解, 即dump下來的log文本文件. ndk-stack會分析此文件.
  • -sym參數就是你android項目下,編譯成功以後,obj目錄下的文件.

示範一下:c++

$ adb logcat | ndk-stack -sym ./obj/local/armeabi ********** Crash dump: ********** Build fingerprint: 'htc_wwe/htc_bravo/bravo:2.3.3/ GRI40/96875.1:user/release-keys' pid: 1723, tid: 1743 >>> com.packtpub.droidblaster <<< signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0000000c Stack frame #00 pc 00010a2c /data/data/com.packtpub.droidblaster/lib/libdroidblaster.so: Routine update in /home/packt/Project/Chapter11/DroidBlaster_Part11/jni/TimeService.cpp:25 Stack frame #01 pc 00009fcc /data/data/com.packtpub.droidblaster/lib/libdroidblaster.so: Routine onStep in /home/packt/Project/Chapter11/DroidBlaster_Part11/jni/DroidBlaster.cpp:53 Stack frame #02 pc 0000a348 /data/data/com.packtpub.droidblaster/lib/libdroidblaster.so: Routine run in /home/packt/Project/Chapter11/DroidBlaster_Part11/jni/EventLoop.cpp:49 Stack frame #03 pc 0000f994 /data/data/com.packtpub.droidblaster/lib/libdroidblaster.so: Routine android_main in /home/packt/Project/Chapter11/DroidBlaster_Part11/jni/Main.cpp:31ref from:http://www.cnblogs.com/jhzhu/p/3801640.html
相關文章
相關標籤/搜索